Subject | Q. Fastest way to insert ~6000 rows |
---|---|
Author | tickerboo2002 |
Post date | 2004-05-13T10:37:27Z |
In one of my Apps, when a user imports some data, I have to insert:
6000 rows into table x
6000 rows into table y
2000 rows into table z
At the moment, I use the following code:
sqlAddX->BeginBusy( true );
sqlAddX->Prepare();
sqlAddY->BeginBusy( true );
sqlAddY->Prepare();
sqlAddZ->BeginBusy( true );
sqlAddZ->Prepare();
TIB_Column * pColzID= sqlAddZ->ParamByName("Z_ID");
TIB_Column * pColzDesc = sqlAddZ->ParamByName("Z_DESC");
// loop here
pColzID->AsInteger = nID;
pColzDesc->AsString = sDesc;
sqlAddZ->ExecSQL();
+ the same for table x & y
sqlAddX->Unprepare();
sqlAddX->EndBusy();
sqlAddY->Unprepare();
sqlAddY->EndBusy();
sqlAddZ->Unprepare();
sqlAddZ->EndBusy();
sqlAddZ->IB_Transaction->Commit();
Is this the optimum way, or would I be better off using a TIB_Query?
Also, for such relatively small numbers, would disabling the table
Indexes help much? Is it possible to disable the tables' PK index
while I'm inserting?
TIA
David
6000 rows into table x
6000 rows into table y
2000 rows into table z
At the moment, I use the following code:
sqlAddX->BeginBusy( true );
sqlAddX->Prepare();
sqlAddY->BeginBusy( true );
sqlAddY->Prepare();
sqlAddZ->BeginBusy( true );
sqlAddZ->Prepare();
TIB_Column * pColzID= sqlAddZ->ParamByName("Z_ID");
TIB_Column * pColzDesc = sqlAddZ->ParamByName("Z_DESC");
// loop here
pColzID->AsInteger = nID;
pColzDesc->AsString = sDesc;
sqlAddZ->ExecSQL();
+ the same for table x & y
sqlAddX->Unprepare();
sqlAddX->EndBusy();
sqlAddY->Unprepare();
sqlAddY->EndBusy();
sqlAddZ->Unprepare();
sqlAddZ->EndBusy();
sqlAddZ->IB_Transaction->Commit();
Is this the optimum way, or would I be better off using a TIB_Query?
Also, for such relatively small numbers, would disabling the table
Indexes help much? Is it possible to disable the tables' PK index
while I'm inserting?
TIA
David