This is a tricky one, and not sure anybody has any idea about this, but let me try to explain.
I have a large (about 0.5 Gb) SQLite db file, which I make on a work PC (Win XP) with VBA/VB6. The SQLite version here is 3.6.1. I then copy this file to a USB stick and take it home where I copy this file to the home PC, Win XP as well. I then copy the file to the mobile device, a Samsung Omnia. It goes the internal storage, called My Storage. This is not a card.
Now I run a number of queries like this:
SELECT EXISTS(
SELECT PATIENT_ID FROM TABLE_X
WHERE PATIENT_ID = @value1)
PATIENT_ID is an INTEGER PRIMARY KEY and these tables are not that large, but this query can be slow, say about one second.
Now the strange thing.
I now make a trivial change (set Read-Only to True and then back to False)
to the db file on the home PC and copy that file to the device again, so over-writing the old SQLite file.
I then run the same queries again and they are a lot faster, say 20 milli-seconds. Apart from that trivial change the fiiles are otherwise exactly the same and the SQLite query plans for both queries are the same.
It is not a cache effect as I can reverse it from fast to slow by copying the
first file (without the trivial change) to the device again.
All this is not entirely consistent, so sometimes the trivial change may not make the queries go faster.
Doing the same change (Read-Only True and then False) on the device unfortunately doesn't make it go fast.
So, what possibly could be going on here?
The slow queries are a problem, so I need to figure out what is doing this and how to prevent/solve it.
Any ideas/suggestions?
RBS
I have a large (about 0.5 Gb) SQLite db file, which I make on a work PC (Win XP) with VBA/VB6. The SQLite version here is 3.6.1. I then copy this file to a USB stick and take it home where I copy this file to the home PC, Win XP as well. I then copy the file to the mobile device, a Samsung Omnia. It goes the internal storage, called My Storage. This is not a card.
Now I run a number of queries like this:
SELECT EXISTS(
SELECT PATIENT_ID FROM TABLE_X
WHERE PATIENT_ID = @value1)
PATIENT_ID is an INTEGER PRIMARY KEY and these tables are not that large, but this query can be slow, say about one second.
Now the strange thing.
I now make a trivial change (set Read-Only to True and then back to False)
to the db file on the home PC and copy that file to the device again, so over-writing the old SQLite file.
I then run the same queries again and they are a lot faster, say 20 milli-seconds. Apart from that trivial change the fiiles are otherwise exactly the same and the SQLite query plans for both queries are the same.
It is not a cache effect as I can reverse it from fast to slow by copying the
first file (without the trivial change) to the device again.
All this is not entirely consistent, so sometimes the trivial change may not make the queries go faster.
Doing the same change (Read-Only True and then False) on the device unfortunately doesn't make it go fast.
So, what possibly could be going on here?
The slow queries are a problem, so I need to figure out what is doing this and how to prevent/solve it.
Any ideas/suggestions?
RBS