sqlite in memory vs IMPBDB
Posted: Wed Dec 18, 2024 11:02 am
I would like to get an unbiased test of sqlite using this file customers-100000.csv
From github repo https://github.com/datablist/sample-csv ... me-ov-file
1st query. First names beginning with "a" from New Zealand
2nd query customers from France
IMPBDB results single thread on 2.75ghz I5
I'm just curious to see how SQLite performs
From github repo https://github.com/datablist/sample-csv ... me-ov-file
1st query. First names beginning with "a" from New Zealand
2nd query customers from France
Code: Select all
Structure CUSTOMER
Index.s
CustomerId.s
FirstName.s
LastName.s
Company.s
City.s
Country.s
Phone1.s
Phone2.s
Email.s
SubscriptionDate.s
Website.s
EndStructure
Procedure loadCVS(*db.IIMPBDB,file.s) ;import the CVS to DB
Protected fn,str.s,ct,ct1
fn = ReadFile(#PB_Any,file.s)
If fn
str = ReadString(fn,#PB_UTF8)
Debug str
While Not Eof(fn)
str = ReadString(fn,#PB_UTF8)
*cust.Customer = AllocateStructure(customer)
If *cust
*cust\Index = StringField(str,1,",")
*cust\CustomerId = StringField(str,2,",")
*cust\FirstName = StringField(str,3,",")
*cust\LastName = StringField(str,4,",")
*cust\Company = StringField(str,5,",")
*cust\City = StringField(str,6,",")
*cust\Country = StringField(str,7,",")
*cust\Phone1 = StringField(str,8,",")
*cust\Phone2 = StringField(str,9,",")
*cust\Email = StringField(str,10,",")
*cust\SubscriptionDate = StringField(str,11,",")
*cust\Website = StringField(str,12,",")
;insert into sqlite
Else
Debug "error"
EndIf
Wend
EndIf
EndProcedure
Global DBfile.s = GetTemporaryDirectory() + "customers.json"
*db.IIMPBDB = IMPBDB_OpenDB("customers",DBfile,0)
If FileSize(DBfile) < 1
loadCVS(*db,GetPathPart(ProgramFilename())+"customers-100000.csv")
EndIf
;The pb query's
*ls.IMPBDB_List = *db\Enum(0,"names:A") ;query names beginning with A
ForEach *ls\results()
*cust.customer = *ls\results()\value
If UCase(*cust\Country) = "NEW ZEALAND" ;filter the results for country
PrintN(*cust\FirstName + " " + *cust\LastName)
EndIf
Next
FreeStructure(*ls)
*ls.IMPBDB_List = *db\Enum(0,"countries:FRANCE")
ForEach *ls\results()
*cust.customer = *ls\results()\value
PrintN(*cust\FirstName + " " + *cust\LastName)
Next
FreeStructure(*ls)
Customers Names beginning with "A" from New Zealand
Query time 2ms
Aaron Woodward
...
Austin Schmitt
Customers from France
Query time 0ms
Billy Benjamin
...
Jackie Phelps
I'm just curious to see how SQLite performs