Sobes.tech
Senior

Is it possible to create indexes on 15 columns in a table at once?

sobes.tech AI

Answer from AI

In most DBMS, it is technically possible to create a composite index including up to 15 fields, but this is highly inefficient and rarely justified. Indexes on a large number of columns:

  • Increase the size of the index, slowing down insert and update operations.
  • May not be used by the query optimizer if filters do not match the beginning of the composite index.

It is better to create indexes on the most frequently used fields in WHERE and JOIN conditions, usually 2-3 columns. If you need to cover many fields, consider revising the data structure or using other optimization methods.

Example of creating a composite index in SQL:

CREATE INDEX idx_example ON table_name (field1, field2, field3);

Creating an index on 15 fields at once is technically possible, but it is considered poor practice.