From: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
---|---|
To: | andreas(dot)fredriksson(at)pacer(dot)se |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] SubQuery speed |
Date: | 1998-09-08 15:10:50 |
Message-ID: | l03110703b21af7eb7bd6@[147.233.159.109] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
At 16:45 +0200 on 8/9/98, andreas(dot)fredriksson(at)pacer(dot)se wrote:
> Are there any alternate methods of solving this? I don't think it's
> possible to write this kind of query using a multi-JOIN?
Why not? So long as the query is "in", and not "not in"?
Should be something like:
SELECT DISTINCT url,title
FROM idx_files, idx_ref, idx_words
WHERE idx_files.id = idx_ref.file_id
AND idx_ref.word_id = idx_words.id
AND (idx_words.word = 'search term 1' OR .. );
In any case, are there indices on the appropriate fields?
If the innermost query is supposed to return only one tuple, you should use
"=" rather than IN, although I don't know how much that adds. The optimizer
probably has an easier time with "=" than with IN.
Herouth
--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma
From | Date | Subject | |
---|---|---|---|
Next Message | Leslie Mikesell | 1998-09-08 16:36:58 | Re: [SQL] Looking for easy SQL documentation! |
Previous Message | Kevin O' Gorman | 1998-09-08 14:54:52 | Re: [SQL] Looking for easy SQL documentation! |