SmugX has asked for the wisdom of the Perl Monks concerning the following question:
Hello all.
I want to mirror a database table from location A to location B. I only require location B to hold a subset of the information in A - that I'd define simply by a query. The mirror is one way, as location B is read-only. I don't need the mirror to be "live", so I plan to run a DBI-based perl script every hour or two that updates location B. So far, so simple. :-)
What I'm looking for is an efficient and easy way to do this. My first thought was to copy the whole table from A to a temporary table in B, and do a rename to make this the current table. However, this seems a tad inefficient (the table has many rows which don't change often, and I'd be doing many INSERTs), and this does leave table B non-existant for a brief period, which isn't ideal with people constantly querying it.
Alternatively, I could query both databases, and do a bunch of comparisons to see which rows would need adding, which deleting, which updating - and then perform the relevant INSERT/DELETE/UPDATE queries. This approach sounds more promising, but so generic that I wondered if there were any existing modules to perform mirroring in this fashion - or, indeed, if there's a better approach. I've tried CPAN searching for "dbi mirror", but haven't really found anything that looks applicable. Maybe I'm being thick, however!
Does anyone have any pointers for me?
Many thanks,
Neil.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Searching for Module to Mirror Database Table
by john_oshea (Priest) on Jan 19, 2006 at 18:03 UTC | |
|
Re: Searching for Module to Mirror Database Table
by NiJo (Friar) on Jan 19, 2006 at 19:51 UTC | |
by SmugX (Beadle) on Jan 20, 2006 at 10:24 UTC | |
|
Re: Searching for Module to Mirror Database Table
by shiza (Hermit) on Jan 19, 2006 at 19:34 UTC | |
by SmugX (Beadle) on Jan 20, 2006 at 10:13 UTC | |
|
Re: Searching for Module to Mirror Database Table
by kulls (Hermit) on Jan 20, 2006 at 08:18 UTC | |
|
Re: Searching for Module to Mirror Database Table
by radiantmatrix (Parson) on Jan 20, 2006 at 17:11 UTC | |
|
Re: Searching for Module to Mirror Database Table
by simonm (Vicar) on Jan 23, 2006 at 17:28 UTC |