Re: please help on query

From: Hannu Krosing <hannu(at)tm(dot)ee>
To: Luis Alberto Amigo Navarro <lamigo(at)atc(dot)unican(dot)es>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: please help on query
Date: 2002-07-11 21:08:15
Message-ID: 1026421695.18194.24.camel@taru.tm.ee
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

On Thu, 2002-07-11 at 17:22, Luis Alberto Amigo Navarro wrote:
> I can't improve performance on this query:

This _may_ work.

SELECT
supplier.name,
supplier.address
FROM
supplier,
nation,
WHERE supplier.suppkey IN (
SELECT part.partkey
FROM part
WHERE part.name like 'forest%'
INNER JOIN partsupp ON part.partkey=partsupp.partkey
INNER JOIN (
SELECT 0.5*(sum(lineitem.quantity)::FLOAT) as halfsum
FROM lineitem
WHERE lineitem.partkey=partsupp.partkey
AND shipdate >= '1994-01-01'
AND shipdate < '1995-01-01'
) li ON partsupp.availqty > halfsum
)
AND supplier.nationkey=nation.nationkey
AND nation.name='CANADA'
ORDER BY supplier.name;

---------------
Hannu

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hannu Krosing 2002-07-11 21:20:39 Re: [pgaccess-users] RE: [HACKERS] bugzilla.pgaccess.org
Previous Message Hannu Krosing 2002-07-11 20:51:04 Re: please help on query

Browse pgsql-sql by date

  From Date Subject
Next Message Loyd Goodbar 2002-07-11 22:08:52 Re: SQL problem with aggregate functions.
Previous Message Hannu Krosing 2002-07-11 20:51:04 Re: please help on query