On 8/14/16, Венцислав Русев <ven...@proxima-3.com> wrote: > My computer has 4 cores. I have compile sqlite like this "gcc > -DSQLITE_MAX_WORKER_THREADS=4 -DSQLITE_DEFAULT_WORKER_THREADS=4 shell.c > sqlite3.c -lpthread -ldl -o sqlite3". I made some tests and found that > "pragma threads = 4" doesn't decrease runtime of the query that sorts 1 > milion records. > > SQLite version 3.8.8 > sqlite> pragma threads; > 4 > sqlite> CREATE TABLE event ( > ID INTEGER PRIMARY KEY NOT NULL, > date INTEGER NOT NULL, > value INTEGER NOT NULL ); > sqlite> EXPLAIN QUERY PLAN SELECT ID FROM event ORDER BY date LIMIT 1;
The algorithm used for "ORDER BY ... LIMIT N" uses much less memory than a full-up "ORDER BY" because is only keeps track of the top N entries seen so far, discarding the rest. But it also only uses a single thread. If you want multiple threads to be used, you'll need to drop the LIMIT, though I imagine that would defeat your purpose, no? -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users