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.

Speeding Up PostgreSQL with Partial Indexes

98 pointsby drobover 10 years ago

4 comments

infogulchover 10 years ago
What about one multiple-column index? Using three separate indexes on three columns is almost never ideal so I don&#x27;t know why it was considered in the first place (unless to make a contrived &quot;normal&quot; to compare partial indexes against).<p>My guess would be: nearly the same read performance as the partial index, a bit less than half the storage of three separate indexes. The write performance isn&#x27;t as &quot;free&quot; as the partial index, but it&#x27;s a third of three separate indexes and still allows for many more types of queries than the partial index.
评论 #8730855 未加载
评论 #8731298 未加载
评论 #8731309 未加载
chdirover 10 years ago
In case of Django, the RunSQL command [1] in migrations makes it very easy to use partial indexes. There are a couple of examples on Stackoverflow. Definitely a low hanging fruit and worth those 10-20 minutes to setup.<p>[1] <a href="https://docs.djangoproject.com/en/dev/ref/migration-operations/#runsql" rel="nofollow">https:&#x2F;&#x2F;docs.djangoproject.com&#x2F;en&#x2F;dev&#x2F;ref&#x2F;migration-operatio...</a>
dsugarmanover 10 years ago
this is a really cool feature I did not know about. just curious, why do you use such crazy json in postgres? why not store the data with relational database standards?
评论 #8731110 未加载
评论 #8732261 未加载
评论 #8731159 未加载
评论 #8731153 未加载
losvedirover 10 years ago
This is a cool feature.<p>Unfortunately, when I looked into this for our codebase, I found that it doesn&#x27;t have full support in Rails 3. You can make the index, via a migration, but rails won&#x27;t include it properly in your `schema.rb` file. So restoring via schema (as opposed to running through all your migrations from scratch) or just trying to understand your database by looking at schema.rb won&#x27;t give you a full picture.<p>However, looking at `add_index` in rails 4, it seems to support it!<p>edit: one thing I did try out was you can change your schema file from `schema.rb` to `schema.sql`, which supposedly fixes it, but I had some issues with that which I don&#x27;t remember at the moment.
评论 #8732133 未加载
评论 #8731931 未加载
评论 #8733186 未加载
评论 #8731903 未加载