PL SQL - 快速删除
我有一个每天存储数百万条记录的表(即第一天 y,000,000 条,第二天前 y,000,000 条记录 + x,000,000 条新记录等)。我想通过每小时的过程删除特定记录(假设这些记录的 id_name='PB-HQ'),但使用命令 DELETE 需要足够的时间,因为每次过程运行时都会从头开始逐行搜索表。还有其他解决方案吗(使用 cusror-fetch ???)
I have a table which stores million of records per day (i.e. 1st day y,000,000, 2nd day previous y,000,000 records + x,000,000 new etc). I want to delete specific records (assume these with id_name='PB-HQ') through an hourly procedure but using the command DELETE it takes enough time as the table every time the procedure runs is searched from the beginning row by row. Is there any other solution (using cusror-fetch ???)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一种选择是按 id_name 对表进行分区(可能是基于列表的分区),然后您所要做的就是截断“PB-HQ”的分区。
One option is to partition the table by id_name (perhaps a list-based partition), then all you have to do is truncate the partition for 'PB-HQ'.
为什么?如果您不希望表中包含 id_name = 'PB-HQ' 的记录,也许更好的解决方案是不插入它们,而不是每小时删除它们。如果您暂时需要它们,请放入另一个表并查看截断表。
Why? If you don't want records with id_name = 'PB-HQ' in the table, maybe the better solution would be to not insert them, instead of deleteing every hour. Of if you need them for awhile, put in another table and look at truncate table.