ODBC MFC CRecordSet performance
Posted on 1999-01-21
I am writing a family tree program in Visual C++ 4.0 using local ODBC links to Paradox 5.0 or Access 97 (the final choice is immaterial unless one turns out to be significantly better than the other). I am using CRecordSet derived objects to provide the data needed to draw the tree on screen. The idea is to navigate around the tree with the mouse, each double click redrawing a restricted portion of the tree focused on the person where the click occurred. Unfortunately it takes about 17 seconds to redraw, the delay being caused by requerying the recordsets. This makes the program somewhat unusable and I haven't yet even created all the recordsets that will eventually be required. Can anyone suggest ways I might speed things up a bit?
Things I have already tried include the following:
* Closing recordsets in between use and opening them again when a requery would be needed. This was suggested by a company called DevCentral on the grounds that a lot of open recordsets take up a large amount of RAM. Unfortunately this approach takes even longer than when they are left open and requeried as necessary.
* Using a single global CDatabase object and passing this to the CRecordSet constructors instead of letting them create their own individual connections. This has been my approach from the start and was also suggested by DevCentral.
* Using queries which reside in the database instead of submitting SQL from the C++ program. I have been unable to get Access queries to accept parameters submitted via ODBC (they expect to present interactive users of Access with a dialog box) and have failed to access Paradox queries at all via ODBC. Calling a query from Access which did not require parameters still took about the same length of time.
* Using less recordsets to obtain the same information. I wrote a single recordset with a long cumbersome SQL statement to obtain all of the information required in one go but because there were so many more fields to return this still took as long as using lots of smaller recordsets.
* Only obtaining minimal information to draw the tree, querying for additional information as required (photos, text entries etc). In fact the information so far being requested is minimal because I am still testing prototypes of this application. If I used any less information there would be nothing to display at all.
* Not changing details of the recordset in between requeries, except for the parameter data member(s). This was suggested in the Visual C++ help system and is what I am doing in any case. The fact that the help system mentioned performance at all leaves me somewhat pessimistic.
Is ODBC always this slow or am I not using it right? Any help or suggestions gratefully received.