postgres 计数或求和忽略脏东西
我有一个索引,其中必须总结的信息位于索引中。索引看起来像这样 (key,sumable_attribute)
。
现在如果我说:
SELECT sum(sumable_attribute) from table where key between 1 and 1000000
如果我们能够沿着 b 树的链接叶子运行并收集 sumable_attributes,那就完美了。
但是:MVCC 告诉我们检查数据的可见性...我不在乎我的结果是否不是 100% 正确,只要它很快。 MyISAM 有点快...
我如何告诉 postgres 忽略这个?
I have an index where the information that has to be summed up is in the index. Index looks like this (key,sumable_attribute)
.
Now if I say:
SELECT sum(sumable_attribute) from table where key between 1 and 1000000
It would be perfect if we can run along the linked leafs of the b-tree and collect the sumable_attributes.
BUT: MVCC tells us to check the visibility of the data... I don't care if my result isn't 100% correct, as long as it is fast. MyISAM kind of fast...
How do I tell postgres to ignore this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PostgreSQL 目前实现两种不同的隔离级别:“读已提交”和“可序列化”。您可以使用 READ UNCOMMITTED 请求脏读,但您将获得“读已提交”隔离级别。
由于 READ COMMITTED 是默认设置,因此您可能正在使用 PostgreSQL 提供的最快隔离级别。
但是发布 EXPLAIN ANALYZE query_name_or_sql_statement 的输出可能会给我们一些想法。
PostgreSQL currently implements two distinct isolation levels: "Read Committed" and "Serializable". You can ask for a dirty read with
READ UNCOMMITTED
, but you'll get "Read Committed" isolation level instead.Since
READ COMMITTED
is the default, you're probably using the fastest isolation level PostgreSQL offers.But posting the output of
EXPLAIN ANALYZE query_name_or_sql_statement
might give us some ideas.