class HasHints(object):
Known subclasses: sqlalchemy.orm.query.Query
, sqlalchemy.sql.expression.Select
Undocumented
Method | with_hint |
Add an indexing or other executional context hint for the given selectable to this _expression.Select or other selectable object. |
Method | with_statement_hint |
Add a statement hint to this _expression.Select or other selectable object. |
Class Variable | _has_hints_traverse_internals |
Undocumented |
Class Variable | _hints |
Undocumented |
Class Variable | _statement_hints |
Undocumented |
Add an indexing or other executional context hint for the given
selectable to this _expression.Select
or other selectable
object.
The text of the hint is rendered in the appropriate
location for the database backend in use, relative
to the given _schema.Table
or _expression.Alias
passed as the
selectable argument. The dialect implementation
typically uses Python string substitution syntax
with the token %(name)s to render the name of
the table or alias. E.g. when using Oracle, the
following:
select(mytable).\ with_hint(mytable, "index(%(name)s ix_mytable)")
Would render SQL as:
select /*+ index(mytable ix_mytable) */ ... from mytable
The dialect_name option will limit the rendering of a particular hint to a particular backend. Such as, to add hints for both Oracle and Sybase simultaneously:
select(mytable).\ with_hint(mytable, "index(%(name)s ix_mytable)", 'oracle').\ with_hint(mytable, "WITH INDEX ix_mytable", 'sybase')
See Also
_expression.Select.with_statement_hint
Add a statement hint to this _expression.Select
or
other selectable object.
This method is similar to _expression.Select.with_hint
except that
it does not require an individual table, and instead applies to the
statement as a whole.
Hints here are specific to the backend database and may include directives such as isolation levels, file directives, fetch directives, etc.
See Also
_expression.Select.with_hint
_expression.Select.prefix_with
- generic SELECT prefixing
which also can suit some database-specific HINT syntaxes such as
MySQL optimizer hints