Subject Archiving data
Author Riho-Rene Ellermaa
Hi!

I'm periodically archiving old data from one (working) database to
another (archive).
Being a lazy programmer I use for that purpose 2 queries that share
common transaction
First query points connects to work database and another to archive.

Trans->StartTransaction();
while(!QFrom->Eof)
{
sRowData = QFrom->Fields->RowData;
QTo->Insert();
QTo->Fields->RowData = sRowData;
QTo->Post();
}
SQLFromDelete->ExecSQL() //deletes old records from work
database
Trans->Commit();

The SQL of the queries is generated using the list of tables - "select
* from %s"

This approach works OK for "normal" users, but now I encountered one who
has LOTS of data in one table (structure is at the end of mail).
Each Post() added approx. 200 KB to the memory usage and my computer run
out of memory very fast.

I'm probably doing something very wrong/stupid here. Why so big memory
consumption?


CREATE TABLE STAT_HISTORY (
ACCID INTEGER NOT NULL,
SDATE DATE NOT NULL,
ROW INTEGER NOT NULL,
OPTYPE VARCHAR(3) CHARACTER SET WIN1252,
DOCNO VARCHAR(10) CHARACTER SET WIN1252,
CD VARCHAR(2) CHARACTER SET WIN1252,
AMOUNT DOUBLE PRECISION,
CURRENCY VARCHAR(3) CHARACTER SET WIN1252,
BANKREF BANKREF,
CREF CREF,
REGNO VARCHAR(11) CHARACTER SET WIN1252,
LOCALAMOUNT DOUBLE PRECISION,
BACCOUNT VARCHAR(50) CHARACTER SET WIN1252,
BANK VARCHAR(35) CHARACTER SET WIN1252,
REQUEST_ID INTEGER,
RUNBAL DOUBLE PRECISION,
CUST_CODE VARCHAR(16) CHARACTER SET WIN1252,
CUST_CODE2 VARCHAR(16) CHARACTER SET WIN1252,
IACCOUNT ACCOUNT,
FACCOUNT ACCOUNT,
INAME LT_BENNAME,
FNAME LT_BENNAME,
IREGNO VARCHAR(11) CHARACTER SET WIN1252,
FREGNO VARCHAR(11) CHARACTER SET WIN1252,
DETAILS LT_DETAILS,
NAME LT_BENNAME,
UNAME LT_BENNAME,
PRIMARY KEY (ACCID,SDATE,ROW)
);

Riho Ellermaa