class HasHints: (source)
Known subclasses: sqlalchemy.orm.query.Query
, sqlalchemy.sql.selectable.Select
Undocumented
Method | with |
Add an indexing or other executional context hint for the given selectable to this :class:`_expression.Select` or other selectable object. |
Method | with |
Add a statement hint to this :class:`_expression.Select` or other selectable object. |
Method | _with |
Undocumented |
Class Variable | _has |
Undocumented |
Class Variable | _hints |
Undocumented |
Class Variable | _statement |
Undocumented |
def with_hint(self, selectable:
_FromClauseArgument
, text: str
, dialect_name: str
= '*') -> Self
:
(source)
¶
Add an indexing or other executional context hint for the given selectable to this :class:`_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 :class:`_schema.Table` or :class:`_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", 'mssql') .. seealso:: :meth:`_expression.Select.with_statement_hint`
Add a statement hint to this :class:`_expression.Select` or other selectable object. This method is similar to :meth:`_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. .. versionadded:: 1.0.0 .. seealso:: :meth:`_expression.Select.with_hint` :meth:`_expression.Select.prefix_with` - generic SELECT prefixing which also can suit some database-specific HINT syntaxes such as MySQL optimizer hints