I have a dilemma that makes for sort of curious experiment to be conducted but I was wondering if it already has been done.
I have a table:
create table test(action_date date, item_num int, <various irrelevant columns>,
primary key(action_date, item_num));
I have data that is coming in that contains the action_date, item_num and the rest of information for the <various irrelevant columns> I need to update data in the table quickly.
The fastest way I found was to:
- delete the data first
- insert the new data
The issue I am having is how to delete data in the fastest way possible:
The new data contains 1000s of items and 100s of dates, so I can do one of 2 things:
I can do a single query:
delete from test where (item_num = item_num1 and action_date >= action_date1) or (item_num = item_num2 and action_date >= action_date2) or ...Execute as a single transaction a set of queries of the
delete from test where item_num = item_num1 and action_date >= action_date1; delete from test where item_num=item_num2 and action_date >= action_date2; ....
The question is which way would be faster?
P.S. I could conduct experiments and see which way would be faster but I was wondering if this was already done somewhere. My own searches yielded nothing.