Re: Insert Into ... Select, Delte Data
Posted by:
Rick James
Date: September 06, 2014 08:26PM
Ping-pong between two tmp tables. That is, at any one moment, your data-generators are inserting into one tmp table (say. `t1`), while your other script is doing the INSERT ... SELECT FROM `t2` and TRUNCATE TABLE `t2`.
The flip is done by that second script after the TRUNCATE, via:
RENAME TABLE t1 TO x, t2 TO t1, x TO t2;
This is atomic and very fast; it will hang the other script(s) only briefly. Being atomic, there is no risk of missing some inserts.
I don't think there needs to be any timer -- the INSERT-TRUNCATE-RENAME script can simply run as fast as it can.
However, this technique is not really needed unless you have millions of rows in the 'real' table, and data is arriving at a fast rate (hundreds per second).
As Peter says, why have the extra table?
Subject
Written By
Posted
September 06, 2014 02:24PM
September 06, 2014 03:57PM
Re: Insert Into ... Select, Delte Data
September 06, 2014 08:26PM
September 07, 2014 04:07AM
September 07, 2014 11:57AM
September 09, 2014 07:09AM
September 09, 2014 11:31AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.