I am trying to convert my existing RealSQLDatabases to the new SQLiteDatabase. I don’t want to make this a real long post, but I do want to provide enough information for you to understand my situation.
In my application, I download a membership text file from the web and then store the data from the text file in a database. The application has been running great with a RealSQLDatabase class but runs much slower with a SQLiteDatabase class. The time for processing 10,600 membership records has changed from less than 2 seconds to well over 15 minutes.
I did not define a Primary Key in RealSQLDatabase and still do not in the SQLiteDatabase class. In fact, the ONLY changes I made to the code were to redefine the database object as a SQLiteDatabase class instead of a RealSQLDatabase class.
After the database object is instantiated and the file is associated with the database, then the following code creates the database table:
sql_cmd = "Create Table Mbr_DB ( "
sql_cmd = sql_cmd + "Mbr_Nr varchar, "
sql_cmd = sql_cmd + "Mbr_Nr_Pre varchar, "
sql_cmd = sql_cmd + "Mbr_Nr_Suf varchar, "
sql_cmd = sql_cmd + "Mbr_Call varchar, "
sql_cmd = sql_cmd + "Mbr_Name varchar, "
sql_cmd = sql_cmd + "Mbr_City varchar, "
sql_cmd = sql_cmd + "Mbr_SPC varchar, "
sql_cmd = sql_cmd + "Mbr_PastCalls varchar "
sql_cmd = sql_cmd + " )"
G_Mbr_DB.SQLExecute( sql_cmd )
G_Mbr_DB.SQLExecute( "Create Index Mbr_Index on Mbr_DB ( Mbr_Nr, Mbr_Call )" )
After this, the application starts parsing through each membership record in the text file to propagate each field in a Database record.
After the database record has been filled, then the database record is inserted into the database with the following line of code. So there is a loop to process each membership record that looks somewhat like this:
LOOP for each membership record
mbr_db_rec = New DatabaseRecord
File in the data into each field of the database record
G_Mbr_DB.InsertRecord( "Mbr_DB", mbr_db_rec )
END of LOOP
The processing of this loop took less than 2 seconds when using a RealSQLDatabase Class and now takes over 15 minutes using a SQLiteDatabase Class.
Can someone see how to improve the performance ?
Is it wrong to NOT explicitly define a primary key ?
Is the creation of the index causing a problem ?
Thanks in advance.
Ron Bower
Ellicott City, MD