Hello!
Nabble is really wonderful resource, because I received answers to all my
questions. Sorry now, but I have to ask to help me again (if someone could).
I'm not good in sql yet, so if anyone could find a minute to think about
optimization of my sql query I'll be very much obliged.
I have two sqlite databases (I couldn't store all data in one db because of
architecture). In first db there are tables
CREATE TABLE mgWordsRelations (id INTEGER PRIMARY KEY, id_norm INTEGER,
id_norminrel INTEGER, UNIQUE (id_norm,id_norminrel))
CREATE TABLE mgWordsNorm (id INTEGER PRIMARY KEY, wordnorm INTEGER UNIQUE)
In second
CREATE TABLE wform (id INTEGER PRIMARY KEY, wordForm TEXT, ancode TEXT,
wordNorm INTEGER)
I loaded first db and than
ATTACH DATABASE 'second.db' AS Lang

I need to execute query
SELECT wordForm FROM Lang.wform WHERE (ancode='someAncode') AND (wordNorm IN
(SELECT DISTINCT id_norminrel FROM mgWordsRelations WHERE id_norm IN (SELECT
wordNorm FROM Lang.wform WHERE wordForm='someWord'))) ORDER BY RANDOM()
LIMIT 1
of course it is very slow because of nested queries and ordering by random.
How could I optimize it (maybe using UNION or someone else)?
Im looking forward to all comments! Thank you!
-- 
View this message in context: 
http://old.nabble.com/Help-me-please-to-optimize-sql-query-tp26354687p26354687.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to