Re: [sqlite] Help me please to optimize sql query

2009-11-15 Thread Unabashed
Thank you, Simon! Could you please say me what indexes will be correct? I'm trying CREATE INDEX mgwrInd1 ON mgWordsRelations (id_norm) CREATE INDEX mgwrInd2 ON mgWordsRelations (id_norminrel) CREATE INDEX wfInd1 ON wform (wordForm) CREATE INDEX wfInd2 ON wform (wordNorm) CREATE INDEX wfInd3 ON

Re: [sqlite] Help me please to optimize sql query

2009-11-15 Thread Unabashed
Thank you very much! It works well! Igor Tandetnik wrote: > > Try this: > > select wf1.wordForm > from wform wf1 join mgWordsRelations rel on (wf1.wordNorm = > rel.id_norminrel) > join wform wf2 on (rel.id_norm = wf2.wordNorm) > where wf1.ancode = 'someAncode' and wf2.wordForm =

Re: [sqlite] Help me please to optimize sql query

2009-11-14 Thread Simon Slavin
On 15 Nov 2009, at 12:08am, Igor Tandetnik wrote: > select wf1.wordForm > from wform wf1 join mgWordsRelations rel on (wf1.wordNorm = rel.id_norminrel) >join wform wf2 on (rel.id_norm = wf2.wordNorm) > where wf1.ancode = 'someAncode' and wf2.wordForm = 'someWord' > order by random() limit 1;

Re: [sqlite] Help me please to optimize sql query

2009-11-14 Thread Igor Tandetnik
Unabashed wrote: > 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 Try this:

[sqlite] Help me please to optimize sql query

2009-11-14 Thread Unabashed
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