Hi Dan, >[...] > Mutexes are held for the duration of an sqlite3_step() call to make > sure SQLite doesn't segfault when two threads try to access the same > shared-cache object.
Ok, I see, so there is no chance to access the data realy in _parallel_? (Just for reading). > > Any other chance to speed this up (apart from the obvious "optimize the > > query, do not use distinct on large tables....)= > > Without seeing the query or database schema? Not really... Depending > on the exact query an index on "xyz" might help. The database scheme looks like this: static gchar sql_create_table_log[] = "CREATE TABLE IF NOT EXISTS log ( " " key INTEGER, " " timestamp_s INTEGER, " " timestamp_us INTEGER, " " type INTEGER, " " level INTEGER, " " event INTEGER, " " source TEXT, " " dest TEXT, " " text TEXT, " " radio_id INTEGER, " " latitude REAL, " " longitude REAL, " " speed REAL, " " direction INTEGER, " " fix INTEGER, " " alert INTEGER, " " state INTEGER, " " cstate INTEGER, " " PRIMARY KEY (key) " ")"; static gchar sql_create_index_log[] = "CREATE INDEX IF NOT EXISTS timestamp ON log (timestamp_s, timestamp_us)"; The SQL query that takes that much time for each single step is the following: "SELECT DISTINCT radio_id FROM log WHERE event IN (%d, %d) AND timestamp_s >= %ld AND timestamp_s <= %ld" The request that shall be done in parallel is the following: SELECT timestamp_s, timestamp_us, type, level, event, source, dest, text, radio_id, latitude, longitude, speed, direction, key FROM log WHERE (timestamp_s * 1000 + timestamp_us / 1000) > %lld %s AND key > ((SELECT MAX(key) FROM log) -2000) ORDER BY KEY DESC Regards! Ole -- Thermotemp GmbH, Embedded-IT Embedded Hard-/ Software and Open Source Development, Integration and Consulting http://www.embedded-it.de Geschäftsstelle Siegen - Steinstraße 67 - D-57072 Siegen - tel +49 (0)271 5513597, +49 (0)271-73681 - fax +49 (0)271 736 97 Hauptsitz - Hademarscher Weg 7 - 13503 Berlin Tel +49 (0)30 4315205 - Fax +49 (0)30 43665002 Geschäftsführer: Jörg Friedrichs, Ole Reinhardt Handelsregister Berlin Charlottenburg HRB 45978 UstID DE 156329280 _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users