I have a mobile application. My client has a large data set ~100.000 records. It's updated frequently.
When we sync we need to copy from one database to another.
I have attached the second database to the main, and run an insert into table select * from sync.table.
This is extremely slow, it takes about 10 minutes I think.
I noticed that the journal file gets increased step by step.
How can I speed this up?
EDITED 1
I have indexes off, and I have journal off.
Using
insert into table select * from sync.table
it still takes 10 minutes.
EDITED 2
If I run a query like
select id,invitem,invid,cost from inventory where itemtype = 1
order by invitem limit 50
it takes 15-20 seconds.
The table schema is:
CREATE TABLE inventory
('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
'serverid' INTEGER NOT NULL DEFAULT 0,
'itemtype' INTEGER NOT NULL DEFAULT 0,
'invitem' VARCHAR,
'instock' FLOAT NOT NULL DEFAULT 0,
'cost' FLOAT NOT NULL DEFAULT 0,
'invid' VARCHAR,
'categoryid' INTEGER DEFAULT 0,
'pdacategoryid' INTEGER DEFAULT 0,
'notes' VARCHAR,
'threshold' INTEGER NOT NULL DEFAULT 0,
'ordered' INTEGER NOT NULL DEFAULT 0,
'supplier' VARCHAR,
'markup' FLOAT NOT NULL DEFAULT 0,
'taxfree' INTEGER NOT NULL DEFAULT 0,
'dirty' INTEGER NOT NULL DEFAULT 1,
'username' VARCHAR,
'version' INTEGER NOT NULL DEFAULT 15
)
Indexes are created like
CREATE INDEX idx_inventory_categoryid ON inventory (pdacategoryid);
CREATE INDEX idx_inventory_invitem ON inventory (invitem);
CREATE INDEX idx_inventory_itemtype ON inventory (itemtype);
I am wondering, the insert into ... select * from isn't the fastest built-in way to do massive data copy?
EDITED 3
SQLite is serverless, so please stop voting a particular answer, because that is not the answer I'm sure.