Re: Q: Improving INSERT performance using E/SQLC
Posted in 1998
Troy Peterson wrote: > > Hello. > How can I improve the performance of my INSERTs in ESQL/C without exposing > myself to data loss? > > I am using a sql descriptor area which I "put" to and "flush" for each row > I'm adding. If I don't flush after each row then I open myself to data loss > when, let's say, I have 5 rows and the second row I insert violates > referential integrity during the flush. The remaining 3 rows are then lost. > > I really don't want to introduce commit and rollback functions because I'm > writing functions using ESQL/C that are callable from Fortran and the whole > thing is kind of sensitive. > > Is there anything else that I'm missing which would improve performance? Get the source to my dbcopy.ec from my submission to the IIUG software Repository. It uses PUT Cursors, increased buffer size and has complete error recovery from errors detected at FLUSH time. You can use the same logic in your program. The program also uses the IDS FetchArray feature to fetch large numbers of rows in a single FETCH statement and uses that array of FETCHed rows for recovery. If you are reading data from a file or stream you can either save file positions or input records in a local array and use that array for the recovery. The logic is the same. Have fun. BTW the combination of adding the FetchArray code and PUT Cursors increased the performance of dbcopy.ec by 300% (most of the gain coming from the PUT Cursors) so the hassle of having to write robust recovery code in order to use PUT Cursors safely is well worth the effort. Art S. Kagel