SQL Hints
   HOME

TheInfoList



OR:

In various
SQL Structured Query Language (SQL) (pronounced ''S-Q-L''; or alternatively as "sequel") is a domain-specific language used to manage data, especially in a relational database management system (RDBMS). It is particularly useful in handling s ...
implementations, a hint is an addition to the SQL standard that instructs the
database engine A database engine (or storage engine) is the underlying software component that a database management system (DBMS) uses to create, read, update and delete (CRUD) data from a database. Most database management systems include their own application ...
on how to execute the query. For example, a hint may tell the engine to use or not to use an
index Index (: indexes or indices) may refer to: Arts, entertainment, and media Fictional entities * Index (''A Certain Magical Index''), a character in the light novel series ''A Certain Magical Index'' * The Index, an item on the Halo Array in the ...
(even if the
query optimizer Query optimization is a feature of many relational database management systems and other databases such as NoSQL and graph databases. The query optimizer attempts to determine the most efficient way to execute a given query by considering the pos ...
would decide otherwise).


Implementation

Different database engines use different approaches in implementing hints. *
MySQL MySQL () is an Open-source software, open-source relational database management system (RDBMS). Its name is a combination of "My", the name of co-founder Michael Widenius's daughter My, and "SQL", the acronym for Structured Query Language. A rel ...
uses its own extension to the SQL standard, where a
table Table may refer to: * Table (database), how the table data arrangement is used within the databases * Table (furniture), a piece of furniture with a flat surface and one or more legs * Table (information), a data arrangement with rows and column ...
name may be followed by , or keywords. *
Oracle An oracle is a person or thing considered to provide insight, wise counsel or prophetic predictions, most notably including precognition of the future, inspired by deities. If done through occultic means, it is a form of divination. Descript ...
implements hints by using specially-crafted
comment Comment may refer to: Computing * Comment (computer programming), explanatory text or information embedded in the source code of a computer program * Comment programming, a software development technique based on the regular use of comment tags ...
s in the query that begin with a symbol, thus not affecting SQL compatibility. * EDB Postgres Advanced Server (a proprietary version of
PostgreSQL PostgreSQL ( ) also known as Postgres, is a free and open-source software, free and open-source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. PostgreSQL features transaction processing, transactions ...
from
EnterpriseDB EnterpriseDB (EDB) is an American company that provides software and services based on the open-source database PostgreSQL (also known as Postgres), and is one of the largest contributors to Postgres. EDB develops and integrates performance, ...
) offers hints compatible with those of Oracle. *
Microsoft SQL Server Microsoft SQL Server is a proprietary relational database management system developed by Microsoft using Structured Query Language (SQL, often pronounced "sequel"). As a database server, it is a software product with the primary function of ...
offers hints via the keyword MSSQL 2017 Documentation
/ref>


See also

*
Query optimizer Query optimization is a feature of many relational database management systems and other databases such as NoSQL and graph databases. The query optimizer attempts to determine the most efficient way to execute a given query by considering the pos ...
*
Query plan A query plan (or query execution plan) is a sequence of steps used to access data in a SQL relational database management system. This is a specific case of the relational model concept of access plans. Since SQL is declarative, there are typical ...


References

SQL {{database-stub