On Mon, May 31, 2004 at 02:03:09PM +0200, Michael Arndt wrote:
> 
> Problem for this variant: merge table has to be dropped and recreated
>                           periodically.
>                           during the short lag interval the log merge table
>                           does not exist

You don't have to drop and recreate it in MySQL. You can do it under
MySQL's feet without it noticing. The .MRG definition file is simply a
list of tables that make up the merge, with a couple of optional
configuration likes; the only one I use is #INSERT_METHOD.

You can create a new .MRG file very easily in Perl, consisting of the
new range of tables, then move it over the old .MRG, so in one atomic
operation the merge table now has a new subtable; in order to get
MySQL to notice however you have to do a flush tables. You can use
mysqladmin flush-tables to do that.

For insertion, this is where #INSERT_METHOD comes in handy. MySQL can
either insert to the first or last table:

$ tail -3 MessageIDs.MRG
MessageIDs_20040529
MessageIDs_20040530
#INSERT_METHOD=LAST

Now INSERT INTO merge_table will be inserting into
MessageIDs_20040530, which is today. Just after midnight, my Perl runs
and makes a new .MRG, and after the flush MySQL is inserting into the
next table without even realising.
-- 
Chris

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to