Postgres是否有共享查询计划缓存?
我有一个复杂的Postgres查询,该查询已使用PG_HINT_PLAN进行了优化。计划时间约为150ms,而查询时间约为30毫秒。该计划永远不会改变,因此每次查询每次都会收集统计数据。查询的结构性问题是它击中了太多的表。
调整连接倒塌极限和从某些塌陷限制中的效果有限。
大多数“企业”数据库都有共享查询缓存,但据我所知,Postgres没有。
这是什么方法?准备好的陈述并不适合,因为它们的寿命与连接绑定在一起。
I have a complex postgres query that I've optimised with pg_hint_plan. Planning time is about 150ms while query time is about 30ms. The plan should never change, therefore there's no point in gathering statistics each any every time for each query. The structural problem with the query is that it hits too many tables.
Tweaking the join collapse limit and from select collapse limit has limited effect.
Most 'enterprise' databases have a shared query cache, but as far as I can see Postgres does not.
What are ways around this? Prepared statements aren't really suitable as their lifetime is bound to the connection.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有办法解决这个问题。我能想到的最好的解决方案是使用连接池,以便您的连接长期存在,并使用准备好的语句。
There is no way around this. The best solution I can think of is to use connection pooling, so that your connections live for a long time, and use a prepared statement.
没有PostgreSQL没有Microsoft SQL Server或Oracle等计划缓存区域...
它是专业RDBMS的许多区别之一,例如SQL Server ...对于最后一个,
No PostgreSQL does not have a plan cache area like Microsoft SQL Server or Oracle...
It is one of the many differences with professional RDBMS, like SQL Server... For the last one, a complete comparison can be read here