pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: andreas.fredriksson@pacer.se
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] SubQuery speed
Date: Tue, 8 Sep 1998 17:10:50 +0200
Message-ID: <l03110703b21af7eb7bd6@[147.233.159.109]> (raw)
In-Reply-To: <Pine.LNX.4.00.9809081635420.676-100000@zenith.pacer.se>

At 16:45 +0200 on 8/9/98, andreas.fredriksson@pacer.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





view thread (3+ messages)  latest in thread

Message-ID: <l03110703b21af7eb7bd6@[147.233.159.109]>
Permalink:  ../l03110703b21af7eb7bd6@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110703b21af7eb7bd6@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, andreas.fredriksson@pacer.se
  Subject: Re: [SQL] SubQuery speed
  In-Reply-To: <l03110703b21af7eb7bd6@[147.233.159.109]>
  References: <Pine.LNX.4.00.9809081635420.676-100000@zenith.pacer.se> <l03110703b21af7eb7bd6@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox