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 proc开发者_开发知识库edure 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 ???)
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'.
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.
精彩评论