Sobes.tech
Junior — Middle

Is it possible to create a composite index that includes two separate fields in a database?

sobes.tech AI

Answer from AI

Yes, most database management systems can create a composite (compound) index that includes two or more fields. Such an index speeds up queries that filter or sort data based on multiple columns simultaneously.

For example, in SQL, a composite index can be created as:

CREATE INDEX idx_name ON table_name (column1, column2);

This is especially useful if queries with conditions on column1 and column2 are frequently executed.