Oracle 中的动态表分区
我正在为我的应用程序构建一个数据库存储,该存储由一个具有巨大数据量(数亿条记录)的表组成。我计划在日期字段上建立索引,因为我将不时地对给定时间段内的所有记录进行批量恢复(例如,检索第二天的所有记录,午夜) )。
由于记录数量巨大并且性能是该系统中的一个重要问题,我想知道是否有一种方法可以动态对表进行分区,以便我可以更快地检索记录,创建和截断分区,因为它们不是更需要。例如,在处理完今天的记录后,我将如何为第二天创建一个分区并用其余数据填充它?
I'm in the process of building a database storage for my app consisting on a single table with a huge data volume (hundreds of millions of records). I'm planning on having an index on the date field, since I'll be doing a batch recovery of all the records in a given period of time every now and then (for example, retrieving all records for the following day, at midnight).
Since the number of records is huge and performance is an important concern in this system, I would like to know if there is a way I can dynamically partition my table so that I can retrieve the records faster, creating and truncating partitions as they are no longer needed. For example, how would I go about creating a partition for the following day and populating it with the rest of the data after I'm done processing today's records?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在11g中,我们可以定义INTERVAL分区,当Oracle获得键不适合任何现有范围的新记录时,Oracle将自动创建新分区。这是一个非常酷的功能。 了解更多信息。
需要记住的一件事是,分区是企业版许可证之外的一项额外收费。所以使用起来并不便宜。
In 11g we can define INTERVAL partitions, and Oracle will automatically create new partitions when it gets new records whose keys don't fit in any of the existing ranges. This is a very cool feature. Find out more.
One thing to bear in mind is that Partitioning is a chargeable extra on top of the Enterprise Edition license. So it is not cheap to use.
您可以通过使用 动态 SQL。您可以使用 EXECUTE IMMEDIATE 或
DBMS_SQL< /code>
并且您可以使用
DBMS_JOB
或DBMS_SCHEDULER
(DBMS_SCHEDULER
是一项 10g 功能,比DBMS_JOB
更通用)。您可能希望首先手动构建分区语句,然后当您对 DDL 有信心时自动执行该过程。您可以在文档中找到所有合成ALTER TABLE 语句。
you can automate the process of creating or truncating partitions through the use of dynamic SQL. You would write procedures with either EXECUTE IMMEDIATE or
DBMS_SQL
and you would schedule them withDBMS_JOB
orDBMS_SCHEDULER
(DBMS_SCHEDULER
is a 10g feature and is more versatile thanDBMS_JOB
).You probably want to build the partition statements manually first and automate the process later when you are confident with the DDL. You will find all the synthax in the documentation for the ALTER TABLE statement.
这是我想出的使用 SYSDATE 和偏移量创建分区的示例。我必须使用连接到 SYSDATE 的字符串创建替换参数:
Here is a sample of something I came up with for creating partitions using
SYSDATE
and an offset. I had to create replacement parameters with a string concatenated to theSYSDATE
:有一种产品可以自动处理它。 PartitionManager for Oracle 提供基于组织保留的自动分区管理,包括清除和归档旧数据、统计复制等。您可以在 http://www.xyrosoft.com
There's a product that takes care of it automatically. PartitionManager for Oracle provides automatic partition management, based on the organization retention, including purging and archiving old data, statistics copy etc. You can try it out at http://www.xyrosoft.com