Hint (SQL)

In various SQL implementations, a hint is an addition to the SQL standard that instructs the database engine on how to execute the query. For example, a hint may tell the engine to use or not to use an index (even if the query optimizer would decide otherwise).

Implementation

Different database engines use different approaches in implementing hints.

  • MySQL uses its own extension to the SQL standard, where a table name may be followed by {{mono|USE INDEX}}, {{mono|FORCE INDEX}} or {{mono|IGNORE INDEX}} keywords.MySQL 5.5 Reference Manual: [http://dev.mysql.com/doc/refman/5.5/en/index-hints.html 12.2.9.3 Index Hint Syntax]
  • Oracle implements hints by using specially-crafted comments in the query that begin with a {{mono|+}} symbol, thus not affecting SQL compatibility.Mike Ault: [http://www.dba-oracle.com/t_sql_hints_tuning.htm Oracle SQL Hints Tuning]
  • EDB Postgres Advanced Server (a proprietary version of PostgreSQL from EnterpriseDB) offers hints compatible with those of Oracle.{{Cite web |url=http://www.enterprisedb.com/docs/en/9.2/perffeat/Postgres_Plus_Advanced_Server_Performance_Guide-33.htm |title=Postgres Plus Advanced Server Performance and Scalability Guide: Query Optimization Hints |access-date=2013-06-24 |archive-date=2014-04-19 |archive-url=https://web.archive.org/web/20140419011842/http://www.enterprisedb.com/docs/en/9.2/perffeat/Postgres_Plus_Advanced_Server_Performance_Guide-33.htm |url-status=dead }}{{Cite web |url=http://www.enterprisedb.com/docs/en/9.2/oracompat/Postgres_Plus_Advanced_Server_Oracle_Compatibility_Guide-75.htm |title=Postgres Plus Advanced Server Oracle Compatibility Developer's Guide: Optimizer Hints |access-date=2013-06-24 |archive-url=https://web.archive.org/web/20140419012438/http://www.enterprisedb.com/docs/en/9.2/oracompat/Postgres_Plus_Advanced_Server_Oracle_Compatibility_Guide-75.htm |archive-date=2014-04-19 |url-status=dead }}
  • Microsoft SQL Server offers hints via the {{mono|OPTION}} keyword [https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017 MSSQL 2017 Documentation]

See also

References

{{reflist}}

{{DEFAULTSORT:Hint (Sql)}}

Category:SQL

{{database-stub}}