TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Speeding Up PostgreSQL with Partial Indexes

98 点作者 drob超过 10 年前

4 条评论

infogulch超过 10 年前
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 未加载
chdir超过 10 年前
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>
dsugarman超过 10 年前
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 未加载
losvedir超过 10 年前
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 未加载