Re: reading and writing in bulk.
Posted in 2000
Topics: Performance & Tuning
From: David Van Huffel <david.vanhuffel@teleatlas.com>
>
>
>Does there exist a function in the C-api that can read and write to
>informix tables in bulk (something like dbload) ?
>This in order to increase performance for "dumping" and/or "database
>filling" routines. For the moment, everything is working record per
>record, but preformance is not really acceptable. We can work faster
>writing it in ASCII and then afterwards loading it into Informix with
>DBLoad.
onpload (high performance loader)
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
You can read in bulk using the ESQL/C FETCH ARRAY feature. This is
documented and you can look at the code in my dbcopy.ec program for how to
use it. Quickly you set the global variables FetArrSize (number of rows to
fetch in a single FETCH operation) and FetBufSize (size of the transfer
buffer used for array fetching, actually all fetches and puts), prepare and
describe the statement, allocate an array of FetArrSize elements for each
column returned, link the arrays into the sqlda structure, FETCH, and walk
the column arrays in parallel to construct individual records. The two
globals are mutually limiting, ie the number of rows returned is the lesser
of FetArrSize or the number of rows that fit in FetBufSize (which must be
<= 32767). See dbcopy.ec which is contained in the package utils2_ak in
the IIUG Software Repository for an admittedly complex example of using the
FETCH ARRAY feature.
The closes thing to writing in bulk is to use an INSERT CURSOR and PUT to it
after increasing the PUT buffer size using FetBufSize. The rows will
actually be inserted when the buffer is flushed either when it fills or
when you manually FLUSH it. The dbcopy.ec program also shows how this works
which is pretty much how dbload does it.
Using these two features dbcopy is 3x faster than with them disabled!
As Obnoxio points out for single table loading you can use the onpload
utility which can do low level and unlogged loads which are faster still.
Art S. Kagel
Obnoxio The Clown wrote:
>
> From: David Van Huffel <david.vanhuffel@teleatlas.com>
> >
> >
> >Does there exist a function in the C-api that can read and write to
> >informix tables in bulk (something like dbload) ?
> >This in order to increase performance for "dumping" and/or "database
> >filling" routines. For the moment, everything is working record per
> >record, but preformance is not really acceptable. We can work faster
> >writing it in ASCII and then afterwards loading it into Informix with
> >DBLoad.
>
> onpload (high performance loader)
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com