troubleshooting Question

in a multi-column index, how many columns is too many?

Avatar of HappyEngineer
HappyEngineer asked on
PostgreSQL
2 Comments2 Solutions243 ViewsLast Modified:
Let's say I have a table with 5 key columns (I'm picking the number 5 arbitrarily) that I query all the time. If I index too many columns then the index will obviously get large and may end up slowing down queries and inserts/updates/deletes and just end up wasting database ram and disk space.

In the past, if I need to query a table for a single row then I usually create an index which lists all key columns so that the index always goes down to the specific row. Is there a rule of thumb that I should follow to tell me when an index is too specific?

I assume it must be possible to look up the byte size of an index versus the byte size of the corresponding table. Is there a rule of thumb about how the byte size of an index should never be larger than N% of the size of the table it's indexing?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros