class documentation

class HasHints(object):

Known subclasses: sqlalchemy.orm.query.Query, sqlalchemy.sql.expression.Select

View In Hierarchy

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
@_generative
def with_hint(self, selectable, text, dialect_name='*'):

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

def with_statement_hint(self, text, dialect_name='*'):

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.

New in version 1.0.0.

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

_has_hints_traverse_internals =

Undocumented

_hints =

Undocumented

_statement_hints: tuple =

Undocumented