[Dev-C++] RE: ODBC for free tables (Was: SQL "SELECT COUNT(*)" loads whole table into memory)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ed C. <em...@ed...> - 2004-01-04 00:22:46
|
Hi all, I'm going to try rephrasing my question. If I'm using an ODBC driver to connect to a Visual FoxPro (.dbf) data file, can I run queries without loading the whole file into memory? For example, if I just want to count records in a table, I would run the query "SELECT COUNT(*) FROM [c:\somefile.dbf]", but the ODBC driver loads the whole table into RAM = to figure this out. How can I do this better?=20 Thanks for any help. -Ed -----Original Message----- Sent: Friday, January 02, 2004 2:00 AM To: dev...@li... Subject: [Dev-C++] SQL "SELECT COUNT(*)" loads whole table into memory Hi all, Not technically a Dev-Cpp question, but I'm hoping somebody can help, anyway. I'm working with an ODBC driver for Visual FoxPro 6 (as well as = ODBC drivers for several other RDBMSs). My application is supposed to loop through a list of tables, run the single SQL statement "SELECT COUNT(*) = FROM tblname", get the result, then move on. At the end, I go back and tally = all the row counts. In the process, I am simply reusing all my handles (environment, connections, and recordsets), calling SQLGetData and SQLCloseCursor = after each query. Now, here's the problem: even though I'm just doing SELECT COUNT(*), the entire table is getting loaded into memory. My application's memory = usage goes from 6 MB to 100 +, though if I comment out just the FoxPro = database interaction, it stays around 8 MB, where I would expect it to be. The = logic and coding I'm doing for the FoxPro queries is absolutely identical to = the logic I'm using on the other databases, except, of course, for the connection string, and I'm not having this problem with the other = systems. I should also point out that removing some of the larger tables from the = list of tables to check results in an almost perfectly corresponding drop in = RAM usage. For what it's worth, doing the same query directly from Visual FoxPro 6 results in a RAM spike under 1 KB. Anybody know what's wrong? Is there a driver setting I need to use or something? Thanks! -Ed |