vendredi 31 juillet 2015

Improve sqlite perfomance

I have online application, it's using sqlite database, it's containing few tables, one table containing 760k items, other tables containing 3-4k records. All tables have indexes.

I write something in database each 10 seconds. All is good, before i have few visitors on my online app, it's start work really slow, sometimes it just can't return result of query from 760k items table. It's not effect small tables, but only this large table.

Example of table:

"CREATE TABLE IF NOT EXISTS records (id VARCHAR(20) PRIMARY KEY, number INT NOT NULL, timestamp INT NOT NULL, name VARCHAR(20), views BIGINT NOT NULL,  data BINARY(128) NOT NULL, previousRecord VARCHAR(20) NOT NULL, , FOREIGN KEY ( previousRecord ) REFERENCES records ( id ) ON DELETE SET NULL)",

Indexes:

"CREATE UNIQUE INDEX IF NOT EXISTS records_number ON records(number)",

"CREATE INDEX IF NOT EXISTS records_name ON records(name)"

Query than i ran contains joins to other 2-3 tables. When i insert in table i use transaction.

I'm interesting what i can do to improve perfomance on my select requests.

Aucun commentaire:

Enregistrer un commentaire