Sobes.tech
Junior — Middle

Can you list the types of indexes used in SQL and their features?

sobes.tech AI

Answer from AI

In SQL, there are several main types of indexes, each optimized for specific tasks:

  • B-Tree index — the most common type. Suitable for fast searches, sorting, and range queries. Used by default in many DBMS.

  • Hash index — efficient for exact key lookups but does not support range queries or sorting.

  • Bitmap index — well-suited for columns with low cardinality (e.g., gender, status). Used in analytical databases.

  • Full-text index — designed for full-text search on text fields.

  • Spatial index — used for geographic data and spatial queries.

Example of creating a B-Tree index in PostgreSQL:

CREATE INDEX idx_users_name ON users(name);

The choice of index type depends on the nature of the queries and data structure.

Can you list the types of indexes used in SQL and… - sobes.tech