MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _index_query

Method _index_query

lib/sqlalchemy/dialects/oracle/base.py:3228–3278  ·  lib/sqlalchemy/dialects/oracle/base.py::OracleDialect._index_query
(self, owner)

Source from the content-addressed store, hash-verified

3226
3227 @lru_cache()
3228 def _index_query(self, owner):
3229 return (
3230 select(
3231 dictionary.all_ind_columns.c.table_name,
3232 dictionary.all_ind_columns.c.index_name,
3233 dictionary.all_ind_columns.c.column_name,
3234 dictionary.all_indexes.c.index_type,
3235 dictionary.all_indexes.c.uniqueness,
3236 dictionary.all_indexes.c.compression,
3237 dictionary.all_indexes.c.prefix_length,
3238 dictionary.all_ind_columns.c.descend,
3239 dictionary.all_ind_expressions.c.column_expression,
3240 )
3241 .select_from(dictionary.all_ind_columns)
3242 .join(
3243 dictionary.all_indexes,
3244 sql.and_(
3245 dictionary.all_ind_columns.c.index_name
3246 == dictionary.all_indexes.c.index_name,
3247 dictionary.all_ind_columns.c.index_owner
3248 == dictionary.all_indexes.c.owner,
3249 ),
3250 )
3251 .outerjoin(
3252 class="cm"># NOTE: this adds about 20% to the query time. Using a
3253 class="cm"># case expression with a scalar subquery only when needed
3254 class="cm"># with the assumption that most indexes are not expression
3255 class="cm"># would be faster but oracle does not like that with
3256 class="cm"># LONG datatype. It errors with:
3257 class="cm"># ORA-00997: illegal use of LONG datatype
3258 dictionary.all_ind_expressions,
3259 sql.and_(
3260 dictionary.all_ind_expressions.c.index_name
3261 == dictionary.all_ind_columns.c.index_name,
3262 dictionary.all_ind_expressions.c.index_owner
3263 == dictionary.all_ind_columns.c.index_owner,
3264 dictionary.all_ind_expressions.c.column_position
3265 == dictionary.all_ind_columns.c.column_position,
3266 ),
3267 )
3268 .where(
3269 dictionary.all_indexes.c.table_owner == owner,
3270 dictionary.all_indexes.c.table_name.in_(
3271 bindparam(class="st">"all_objects")
3272 ),
3273 )
3274 .order_by(
3275 dictionary.all_ind_columns.c.index_name,
3276 dictionary.all_ind_columns.c.column_position,
3277 )
3278 )
3279
3280 @reflection.flexi_cache(
3281 (class="st">"schema", InternalTraversal.dp_string),

Callers 2

_get_indexes_rowsMethod · 0.95
init_classMethod · 0.95

Calls 9

selectFunction · 0.90
bindparamFunction · 0.85
order_byMethod · 0.45
whereMethod · 0.45
outerjoinMethod · 0.45
joinMethod · 0.45
select_fromMethod · 0.45
and_Method · 0.45
in_Method · 0.45

Tested by

no test coverage detected