TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Understanding database indexes in PostgreSQL

288 pointsby mrpotatoabout 2 years ago

4 comments

fabian2kabout 2 years ago
That was more detailed than I expected, a lot of posts on this topic tend to be more superficial. I suspect the BRIN index might need a bit of a stronger disclaimer, as far as I understand you really want to use that only for ordered data, and in those cases it is exceptionally good at its job. But it is a lot worse if that condition is not met. The post mentions this a bit, but with very soft language.<p>I disagree a bit with &quot;Don’t index columns if the table has little data&quot;, mostly because it doesn&#x27;t matter in those cases. If the table is tiny the index is also very cheap (unless it&#x27;s something really weird like a tiny table that is written at a very high frequency). And &quot;little data&quot; is just not specific enough for people to make decisions unless they already have a very good intuition on when the query planner would use such an index.<p>A rather important part that isn&#x27;t mentioned about multi-column indexes is which kinds of query can use them. That is probably not obvious if you never read about them in detail, but it&#x27;s really important to know when defining them.
评论 #35985381 未加载
评论 #35981947 未加载
评论 #35981512 未加载
评论 #35982154 未加载
paulddraperabout 2 years ago
Wow, this is an excellent article.<p>Two really nice nuggets: how to detect unused and bloated indices.
perlgeekabout 2 years ago
For NULLable columns, does it generally make sense make a partial index with &quot;WHERE column IS NOT NULL&quot;?
abrarkabout 2 years ago
Wow!! This is just awesome about indexing.