all groups > sql server data warehouse > june 2005 >
You're in the

sql server data warehouse

group:

Can I pick your brains for a second? transferring a large database problem.


Can I pick your brains for a second? transferring a large database problem. Scott M
6/6/2005 2:26:18 PM
sql server data warehouse: Okay, I have a problem that I need some suggestions with.

I have a 30 Gig database that I need to sync across a T1 every night. This
database is a data dump of our billing system data, the tables are dropped
ad re-created every night.

I can do a very long and laborious process on the server of creating tables
with the primary keys from each table and a binary checksum of a row, then
complaining it to a copy of the database from the day before. Then I
generate SQL statements for the updates (Actually deletes and inserts). All
of this on the source server.

I'd like to compact this down using a DTS package on the destination side,
however I can't use a dynamic query in the "openRowSet" command to get only
the row that I want.

Here is what I'm doing (Just for one table, I'll have data driven steps for
each table in my DB)

insert into @tempChecker
select BSum, chgNo from openquery(EMBAN2, 'Select BINARY_CHECKSUM(*) BSum,
chgno from charge_t')

Declare Charge_t_Cursor Cursor
FOR
select
a.chgno
from
(select
BSum,
chgno
from @tempChecker
) a
where
not exists
(
select 'x'
from charge_t b
where a.chgno = b.chgno and a.BSum <> BINARY_CHECKSUM(*)
)

Once I get all the chgno's (The key in the table) I want to only pull back
the data that has changes. So I have this (Which I know I can't do put you
get the idea)

Open Charge_t_Cursor

Fetch next from Charge_t_cursor into @ChgNo

While @@FETCH_STATUS = 0
BEGIN
insert into @ChargeT select *
from OPENROWSET(EMBAN2, 'SELECT * FROM charge_t WHERE chgno = ' +
cast(isnull(@ChgNo, 0) as varchar)))

Fetch next from Charge_t_cursor into @ChgNo
END

Close Charge_t_cursor
deallocate Charge_t_cursor

select * from @ChargeT

this way I'm only pulling over the wire the data that is updated and it will
be in a nice, compact binary format. ANY help would be VERY appreciated!!!
Thanks much!

Scott
Re: Can I pick your brains for a second? transferring a large database problem. Peter Nolan
6/21/2005 8:10:28 AM
Hi Scott,
maybe I'm not 'with it' but why do you want to move 30GB of data
between machines just to keep 2 databases in sync?

Do you mean you have two databases being updated and that you then need
BOTH databases to be the same after the syncing process?

Or do you mean you have one database being updated and you need to get
the updates for that one across to the other?

If the second one, and you have absolutely no way to get the changes
from the database you can always do delta file generation.....that is,
dump the tables and compare today vs yesterday, detect the changes and
then send the delta file to the second machine....only a small number
of rows are likely to have changes unless someone is updating lots of
rows for no good reason....I have publised free tools to do this sort
of thing on windows as files to get far better performance than doing
it at a database level.....write to me at peter@peternolan.com if you
want to try them......

Best Regards

Peter
Re: Can I pick your brains for a second? transferring a large database problem. Jéjé
7/3/2005 11:10:20 AM
have you tried to export your tables into flat files, compact these files
(using winzip or anything else)
copy the files and load these files on the destination server.

you could reduce the tranfert from 30gb to 1Gb.
more complex then a DTS pump, but this could be a good solution.

another way...
you can use replication.
or you can create your own "replication" model, I mean add triggers on your
table to log changes into another table in your source system, then load
these changes only every night.

Have you a "last update date" colum in your source tables?

[quoted text, click to view]

Re: Can I pick your brains for a second? transferring a large database problem. Scott M
7/7/2005 6:16:29 PM
It's a huge database that is recreated from our billing software. The
"main" database is housed in a different city and we have a database here
for performance reasons.

[quoted text, click to view]
Re: Can I pick your brains for a second? transferring a large database problem. Peter Nolan
7/8/2005 8:10:47 AM
Hi Scott,
the is seems it is the case that you have one database being updated
and you want a copy of it elsewhere.......

If you have no other way of getting the changed rows (application,
timestamps, log reader, whatever) you can try out our delta generation
utility, we wrote it for a client who had a similar problem......no way
of getting the deltas from the operational system.

It dumps tables and then performs a field my field comparison to see if
a row has changed based on a key defined for the row. I prefer field
by field to CRC because there is always a chance a CRC will return a
false negative...no matter how small.

It's 'brute force' but doing delta generation in files is an order of
magnitude faster than doing them in a database........once you have
generated the deltas you can just send the delta files to your target
server and run the deltas against the target server.....this way you
only transmit the deltas and only perform the number of updates you
need to perform to apply deltas......the 'cost' being the generation of
the deltas in the first place....the software for this is free and
'open source' in that you can download the program source code but not
the classes called by the programs...

Best Regards
Peter Nolan
www.peternolan.com
AddThis Social Bookmark Button