FET_BUF_SIZE or How do I optimize cursor reads? (revisited)
Posted in 2000
In my original posting ("FET_BUF_SIZE or How do I optimize cursor reads?") I had asked whether simply setting the FET_BUF_SIZE environment variable (or the FetBufSize ESQL/C program variable, for that matter) to a high value (32767) would turn on some kind of automatic array fetching by Informix, or whether I would have to recode my application to use fetch arrays to see some performance gain. Well, I received some very different opinions on this, even from some of the regulars in this group (which made me confident that this wasn't merely an RTFM issue...) so I decided to go through the trouble an recode parts of my application for performances testing (using Art's dbcopy.ec as a guideline). Here's what I found out: First of all, I *did not* get any significantly better performance from programming array fetching as opposed to simply setting FetBufSize to the highest possible value. It did make a difference what FetBufSize was set to, obviously: FetBufSize==4096 (the default) was about 15% slower than FetBufSize==32767. Here are some figures I measured (Client/Server over a 10Mbit/s network, Client Sun Solaris 2.6 200MHz UltraSparc 128 MByte RAM, Server Sun Solaris 2.6 200MHz UltraSparc 256 MByte RAM, Informix IDS 7.31, %cached regularly above 98.6%, server more or less idle): SELECT of approx. 56000 records (out of 5.4 million), aligned record size 88 bytes in 9 fields (2 integers, 2 smallints, 2 dates, 2 decimal(10), 1 decimal(20)), average figures singleton fetches, FetBufSize==4096 13.5 sec. singleton fetches, FetBufSize==32767 11.6 sec. array fetches, FetBufSize==32736, FetArrSize==372 11.4 sec. So it seems to me that Informix does indeed fetch chunks of data into a buffer and then serve FETCH commands in ESQL/C from that buffer first before transferring the next chunk. When I took a look at my detailed timings something struck me as odd, though: While I saw a short, expected delay after every 372 records in my array fetch scenario (it took approx. 0.05 sec. fetching a new chunk instead of the usual 0.000035 sec. when serving rows from the buffer), I saw a short, unexpected delay every 4984 (!) records (approx. 0.15 sec. instead of the normal 0.000035 sec.) when I used straightforward singleton fetches. So is there any Informix internal Buffer Size (would have to be something like 88 * 4984 == 438592 bytes) that I am not aware of? Would this be server side or client side or both? If there is a server side buffer of that size, I would assume that the client side buffer of max. 32767 bytes would have to be used by Informix as well but I did not observe any delays at the multiples of 372 rows in that scenario. What do you think? Any opinions are much appreciated. Thanks and Cheers Eckard