如何对主表进行分区?
现在,我正在使用postgresql。在我们的主表中有近1,000,000条记录。我们已经创建了该表的索引,但这会稍微提高性能。所以我们决定对表进行分区。我们认为这是增加索引的正确方法性能..
我需要什么:
如何在 Postgresql 中对表进行分区? 我应该遵循哪些步骤?
Now,am using the postgresql .In our master table nearly 1,000,000 records .we already create the index of this table but it will slightly improve the performance.So we will decide to partition the table.we think it is the right way to increase the performance..
What I need:
How to partition the table in Postgresql ?
What are the steps am i should follow ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您认为为什么需要对表进行分区?我会开始找出问题所在,为什么你的查询太慢。开始使用 EXPLAIN ANALYZE 来查看查询是如何执行的以及执行什么内容可能是问题所在。您能向我们展示查询计划吗?
一百万条记录并不算多,除非每条记录都很大。
Why do you think you need to partion your table? I would start to find out what the problem is, why your queries are too slow. Start using EXPLAIN ANALYZE to see how a query is executed and what might be the problem. Could you show us the queryplan?
A million records is not that much, unless each record is very large.
有关分区的信息,请参阅 POSTGRESQL 帮助文档中的“5.9.2. 实现分区”部分: http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html
我发现这篇文章在将分区表放在一起时提供了非常丰富的信息。我也同意其他人的观点,即 1M 记录在没有分区的情况下仍然应该很快。您的索引可能不会在您的查询中使用,但这将是一个单独问题的主题。
See section "5.9.2. Implementing Partitioning" in POSTGRESQL's help documentation about partitioning: http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html
I found this article incredibly informative when it comes to putting together partitioned tables. I would also agree with everyone else that 1M records should still be fast without a partition. Your index(es) may not be getting used on your queries but that would be the topic for a separate question.