Rows in the base table are uniquely identified by the primary key value defined for the table. The primary key for a table consists of the values ββof one or more columns.
Primary keys are automatically indexed to facilitate efficient information retrieval.
The primary key index is the most efficient way to access the table.
Other columns or column combinations can be defined as a secondary index to improve data retrieval performance. Secondary indexes are defined in the table after its creation (using the CREATE INDEX statement).
An example of when a secondary index can be useful is that a search is performed regularly in a column without a key in a table with many rows, defining an index in a column can speed up the search. The search index does not affect the search result, but the search speed is optimized.
It should be noted, however, that indexes create overhead for update, delete, and insert operations, since the index must also be updated.
Indexes are internal structures that the user cannot explicitly obtain after creation. The index will be used if the process of optimizing internal queries determines it, which will increase the efficiency of the search.
SQL queries are automatically optimized when they are internally prepared for execution. The optimization process determines the most efficient way to complete each request, which may or may not include the use of an applicable index.
source share