Folks, I've been wondering about the overhead of performing a table Open-Close and if I should keep tables open for the duration of my applications. I ran some timing tests on a table with about 3000 dense rows of 20 columns of different types. There were
no large text or binary blobs involved.
I ran loops of 10000 random reads and random updates. My first loop opened and closed the table around each read and write. The second loop performed a single open-close around all reads and writes.
I consistently found that there is a 10% overhead in the first loop.
I conclude therefore that for applications with a moderable to low amount of database activity it is acceptable to Open-Action-Close each time. For cases where you expect a large burst of database activity, then wrapping the Open-Close around all
of the actions would be more efficient.
I hope this finding matches the experience of the ESE authors. Your comments on the subject would be welcome.