* INSERT..ON DUPLICATE KEY UPDATE: See
:ref:`mysql_insert_on_duplicate_key_update`
-* SELECT pragma::
+* SELECT pragma, use :meth:`.Select.prefix_with` and :meth:`.Query.prefix_with`::
- select(..., prefixes=['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
+ select(...).prefix_with(['HIGH_PRIORITY', 'SQL_SMALL_RESULT'])
* UPDATE with LIMIT::
update(..., mysql_limit=10)
+* optimizer hints, use :meth:`.Select.prefix_with` and :meth:`.Query.prefix_with`::
+
+ select(...).prefix_with("/*+ NO_RANGE_OPTIMIZATION(t4 PRIMARY) */")
+
+* index hints, use :meth:`.Select.with_hint` and :meth:`.Query.with_hint`::
+
+ select(...).with_hint(some_table, "USE INDEX xyz")
+
.. _mysql_insert_on_duplicate_key_update:
INSERT...ON DUPLICATE KEY UPDATE (Upsert)
:meth:`.Query.with_statement_hint`
+ :meth:.`.Query.prefix_with` - generic SELECT prefixing which also
+ can suit some database-specific HINT syntaxes such as MySQL
+ optimizer hints
+
"""
if selectable is not None:
selectable = inspect(selectable).selectable
``Query``.
:param \*prefixes: optional prefixes, typically strings,
- not using any commas. In particular is useful for MySQL keywords.
+ not using any commas. In particular is useful for MySQL keywords
+ and optimizer hints:
e.g.::
query = sess.query(User.name).\
prefix_with('HIGH_PRIORITY').\
- prefix_with('SQL_SMALL_RESULT', 'ALL')
+ prefix_with('SQL_SMALL_RESULT', 'ALL').\
+ prefix_with('/*+ BKA(user) */')
Would render::
- SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL users.name AS users_name
- FROM users
+ SELECT HIGH_PRIORITY SQL_SMALL_RESULT ALL /*+ BKA(user) */
+ users.name AS users_name FROM users
.. seealso::
stmt = table.insert().prefix_with("LOW_PRIORITY", dialect="mysql")
+ # MySQL 5.7 optimizer hints
+ stmt = select([table]).prefix_with("/*+ BKA(t1) */", dialect="mysql")
+
Multiple prefixes can be specified by multiple calls
to :meth:`.prefix_with`.
:meth:`.Select.with_hint`
+ :meth:.`.Select.prefix_with` - generic SELECT prefixing which also
+ can suit some database-specific HINT syntaxes such as MySQL
+ optimizer hints
+
"""
return self.with_hint(None, text, dialect_name)