Junior — Middle
Millised indeksitüübid olid kasutusel sinu SQL-päringutes andmete otsingu optimeerimiseks?
sobes.tech AI
Vastus AI-lt
In SQL, the following index types are commonly used to optimize data search:
- B-Tree index — the most common type, suitable for quick search, sorting, and range queries.
- Hash index — efficient for exact key searches but does not support range queries.
- Unique index — guarantees the uniqueness of values in a column and speeds up search.
- Composite index — built on multiple columns, useful for queries filtering on several fields.
- Full-text index — used for fast search in textual data.
Example of creating a composite index:
CREATE INDEX idx_user_lastname_firstname ON users (lastname, firstname);
The choice of index type depends on the nature of the queries and the data structure.