pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Oskar Liljeblad <osk@hem.passagen.se>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] query with subquery abnormally slow?
Date: Mon, 01 Nov 1999 17:10:28 -0500
Message-ID: <2748.941494228@sss.pgh.pa.us> (raw)
In-Reply-To: <19991101194707.A7034@oskar>

Oskar Liljeblad <osk@hem.passagen.se> writes:
> I'm doing a SELECT query with a subquery on a table with 12K rows
> but it is very slow (10 seconds+). The query looks like this:

>   select *
>     from items
>     where package in
>       (select package
>          from items
>          where ...blah...
>          group by package)

Have you considered something like

select i1.* from items i1, items i2 where
i1.package = i2.package and i2.performer ~ '...';

This would only be fast given an index on package, I think,
but you said you had one...

			regards, tom lane



view thread (8+ messages)  latest in thread

Message-ID: <2748.941494228@sss.pgh.pa.us>
Permalink:  ../2748.941494228@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2748.941494228@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, osk@hem.passagen.se
  Subject: Re: [SQL] query with subquery abnormally slow?
  In-Reply-To: <2748.941494228@sss.pgh.pa.us>
  References: <19991101194707.A7034@oskar> <2748.941494228@sss.pgh.pa.us>

* 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