// set cache size to 20000 pages which is about 20 MB for default page sizedim db as REALSQLDatabasedb.SQLExecute "PRAGMA cache_size = 20000"

Notes:
Default cache size is 2000 pages which is not much.
You get best performance if whole database fits in memory.
At least you should try to have a cache big enough so you can do queries in memory.
You only need to call this pragma command once after you opened the database.