gcue

advice to speed up repeated sql queries

11 posts in this topic

hello world!

i am storing user preferences in a sqlite table

Quote

 

user A

target 1, 2, 3, 4, 5.... (saved preference)

each target has multiple entries (which are the results im looking for each target)

 

other users (other than user A) sometimes query the same targets

i would like to find an efficient way of storing each target results so i dont have to query the same targets in subsequent queries.

there several different targets and results change daily so i dont really want to store them back into sql because there may be danger of carrying forward stale data - was hoping to store results for each target in memory somehow then easily using them again for subsequent queries

hope this makes sense

thanks in advance!

Share this post


Link to post
Share on other sites



49 minutes ago, gcue said:

hope this makes sense

I'm afraid it doesn't (at least to me). What is the "danger of carrying forward stale data" and what precludes you from keeping queried data in memory during runtime?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

well i guess i can create a temporary table to hold the data then delete the table upon exit

thanks for the encouragement to find the answer =)

Share this post


Link to post
Share on other sites

A temp table is automagically destroyed when the connection closes. But why not just store the resultset in an array?

OTOH how large is your table and is repeatedly querying the changing data significantly too slow for your application? Aren't you in the premature optimization route?


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

table is not large but the results of each can be up to 1000 results sometimes.  array probably would work best now that i think about it.. because it would just be 1 array.. thanks again for making my gears turn =)

Share this post


Link to post
Share on other sites

If it means anything, I have tested SQLite db with a single table, about 8 columns and 34K rows of data. Returned in 2secs :)

If you go the SQL way, you can simply datestamp the inserts and delete them periodically - keeping only the most recent data


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites
2 hours ago, Skysnake said:

If it means anything, I have tested SQLite db with a single table, about 8 columns and 34K rows of data. Returned in 2secs :)

Are you sure about 2 s response time? That's very poor. You must have a bad schema or you timed an unusually complex query.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Hey @jchd, I was waiting for that comment :)

2sec is from press of button (which triggers the SQL)  till population of GUI ListView:)

 


Skysnake

Why is the snake in the sky?

Share this post


Link to post
Share on other sites

some of the elements are going to be 4,000 characters.  not sure if both routes (array/sql) support that many characters in a single element

any thoughts?

thanks

Share this post


Link to post
Share on other sites

@Skysnake

Ha, this explains why.

@gcue

4k characters is no problem for either AutoIt strings in arrays (or not: strings "Can contain strings of up to 2147483647 characters.") nor SQLite (see https://www.sqlite.org/limits.html where you can read: "The maximum number of bytes in a string or BLOB in SQLite is defined by the preprocessor macro SQLITE_MAX_LENGTH. The default value of this macro is 1 billion (1 thousand million or 1,000,000,000). [continued]").


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

thank you both for your input and help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now