Junior — Middle
In what cases is it permissible to create indexes on all columns of a table in a database?
sobes.tech AI
Answer from AI
Creating indexes on all columns of a table is usually not advisable, as it slows down insert, update, and delete operations, and also increases the amount of memory used. However, it is acceptable to create indexes on all columns if:
- The table is small and queries with filtering on different columns are frequently performed.
- The table is primarily used for reading, not writing.
- Each column is involved in search or sorting conditions.
In most cases, it is better to create indexes only on those columns that are actively used in queries.