beatrice1981
New member
- Local time
- Today, 22:43
- Joined
- Oct 24, 2016
- Messages
- 4
Hi,
Please help
I'm working on a code to loop through the dao.recordset and use single record values as a criteria to set querydef.SQL property then run saved PT query, insert PT query result
into a table and MoveNext.
Code actually works but I can't make my peace with huge db bloat.
I've run several tests and finally deleted most of the code to find the place where IT happens, I hope someone can explain it.
The code below is actually useless for me right now, but this part alone is responsible for ~90% of dbsize after execution.
Dim db1 As DAO.Database
Dim qdef1 As DAO.QueryDef
Dim RST1 As DAO.Recordset
Set db1 = CurrentDb
Set qdef1 = db1.QueryDefs("QDEF01") ‘saved querydef (PT)
Set RST1 = db1.OpenRecordset("SELECT DISTINCT a, b, c , d FROM TAB1")
Do Until RST1.EOF = True
qdef1.SQL = "select field1, field2, field3, field4, field5, field6 FROM SomeTab " '<- evil, evil
Originally there's a whole WHERE clause, but that's irrelevant at the moment
qdef1.Close
RST1.MoveNext
Loop
RST1.Close
Size of db before running (110k recordset) ~40MB, after = ~ 450MB!!!!
I've came up with an idea to replace my original qdef1.SQL string with a simple 'SELECT * from SomeTab' and that was it! Result = dbsize still ~40MB.
It seems like a string itself makes a huge difference, but is it even possible? I need to put a full SQL string into a querydef to make it work but how should I proceed from this point
Am I missing something here? Any ideas will be appreciated.
Please help

I'm working on a code to loop through the dao.recordset and use single record values as a criteria to set querydef.SQL property then run saved PT query, insert PT query result
into a table and MoveNext.
Code actually works but I can't make my peace with huge db bloat.
I've run several tests and finally deleted most of the code to find the place where IT happens, I hope someone can explain it.
The code below is actually useless for me right now, but this part alone is responsible for ~90% of dbsize after execution.
Dim db1 As DAO.Database
Dim qdef1 As DAO.QueryDef
Dim RST1 As DAO.Recordset
Set db1 = CurrentDb
Set qdef1 = db1.QueryDefs("QDEF01") ‘saved querydef (PT)
Set RST1 = db1.OpenRecordset("SELECT DISTINCT a, b, c , d FROM TAB1")
Do Until RST1.EOF = True
qdef1.SQL = "select field1, field2, field3, field4, field5, field6 FROM SomeTab " '<- evil, evil

qdef1.Close
RST1.MoveNext
Loop
RST1.Close
Size of db before running (110k recordset) ~40MB, after = ~ 450MB!!!!
I've came up with an idea to replace my original qdef1.SQL string with a simple 'SELECT * from SomeTab' and that was it! Result = dbsize still ~40MB.
It seems like a string itself makes a huge difference, but is it even possible? I need to put a full SQL string into a querydef to make it work but how should I proceed from this point

Am I missing something here? Any ideas will be appreciated.