wxSQLite3 : Performance Questions Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

wxSQLite3 : Performance Questions

Post by evstevemd »

I have app that loads several SQLIte3 Databases on tabs. Each tab opens its own database handle and I feel that is really expensive.
I wan to to reuse the same database handle to connect to new database fetch data and do the same to next database. Now I want to know if there is difference in performance as I think (that the latter is better) and if there is better way to load multiple database data into Tabs
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
utelle
Moderator
Moderator
Posts: 1125
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: wxSQLite3 : Performance Questions

Post by utelle »

evstevemd wrote:I have app that loads several SQLIte3 Databases on tabs. Each tab opens its own database handle and I feel that is really expensive.
Expensive in which sense? And how is this related to wxSQLite3?

wxSQLite3 is just a thin wrapper for the SQLite API. Allocating a wxSQLite3 handle is a cheap operation. All the hard work is done by SQLite itself.

If you have different database files and if they aren't related to each other, it is usually the best to open a separate connection for each database file. Alternatively you could use the SQLite ATTACH statement to access multiple database files from a single database connection. However, if the databases have tables with identical names you have to be careful to access the right table by using the proper naming scheme.

If you just show on your tabs data from different tables of the same database file, you are better off to use the same database connection for each tab, unless you enable shared cache mode.
evstevemd wrote:I wan to to reuse the same database handle to connect to new database fetch data and do the same to next database.
If you have different database files there is probably only small to no gain in reusing the database handle. Opening and accessing a database file forces SQLite to read and analyze the database schema. If the schema is large this might take some time (although this was never in issue in my own applications).
evstevemd wrote:Now I want to know if there is difference in performance as I think (that the latter is better) and if there is better way to load multiple database data into Tabs
The performance depends on many factors. If you have different database files SQLite needs to load the schema of each file to be able to access the data. This can be a time consuming task. Populating the controls on each tab can also be a time consuming operation depending on the size of the tables involved and depending on how you populate your controls - prefetching all data for all tabs can take a while. Selecting data from tables can also be slow - for example due to complex queries and/or missing indexes.

That is,without more detailed information about the precise situation in your application there is no simple short answer to your question. However, performance issues are seldom related to wxSQLite3.

Regards,

Ulrich
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: wxSQLite3 : Performance Questions

Post by evstevemd »

utelle wrote: That is,without more detailed information about the precise situation in your application there is no simple short answer to your question. However, performance issues are seldom related to wxSQLite3.

Regards,

Ulrich
Thank you. You have actually addressed all my queries.
Sorry for being unspecific. The app itself is quiet complex!
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply