pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masaru Sugawara <rk73@sea.plala.or.jp>
To: Luis Alberto Amigo Navarro <lamigo@atc.unican.es>
Cc: pgsql-sql@postgresql.org
Subject: Re: [HACKERS] please help on query
Date: Tue, 16 Jul 2002 01:15:35 +0900
Message-ID: <20020716011524.3F70.RK73@sea.plala.or.jp> (raw)
In-Reply-To: <005101c22bd3$9ba152d0$cab990c1@atc.unican.es>
References: <20020714211624.9C3E.RK73@sea.plala.or.jp>
	<005101c22bd3$9ba152d0$cab990c1@atc.unican.es>

On Mon, 15 Jul 2002 09:45:36 +0200
"Luis Alberto Amigo Navarro" <lamigo@atc.unican.es> wrote:

> This is the output:
> 
> Aggregate  (cost=0.00..647161.10 rows=600122 width=8) (actual
> time=4959.19..347328.83 rows=62 loops=1)
>   ->  Group  (cost=0.00..632158.04 rows=6001225 width=8) (actual
> time=10.79..274259.16 rows=6001225 loops=1)
>         ->  Index Scan using lineitem_pkey on lineitem
> (cost=0.00..617154.97 rows=6001225 width=8) (actual time=10.77..162439.11
> rows=6001225 loops=1)
> Total runtime: 347330.28 msec
> 
> it is returning all rows in lineitem. Why is it using index?


Sorry, I don't know the reason. 
I need more info. Can you show me the outputs of EXPLAIN ANALYZE ?


EXPLAIN ANALYZE
SELECT
        orders.orderkey
    FROM
        lineitem LEFT OUTER JOIN
        orders USING(orderkey)
    WHERE
        orders.orderkey IS NOT NULL
    GROUP BY
        orders.orderkey
    HAVING
        SUM(lineitem.quantity) > 300;



EXPLAIN ANALYZE
SELECT
      t2.*
FROM (SELECT
                  orders.orderkey
              FROM
                   lineitem LEFT OUTER JOIN
                   orders USING(orderkey)
             WHERE
                   orders.orderkey IS NOT NULL
            GROUP BY
                   orders.orderkey
            HAVING
                    SUM(lineitem.quantity) > 300
           ) AS t1 LEFT OUTER JOIN
           orders AS t2 USING(orderkey)
ORDER BY t2.custkey           


Regards,
Masaru Sugawara





view thread (18+ messages)  latest in thread

Message-ID: <20020716011524.3F70.RK73@sea.plala.or.jp>
Permalink:  ../20020716011524.3F70.RK73@sea.plala.or.jp/
Also on:    postgresql.org/message-id/20020716011524.3F70.RK73@sea.plala.or.jp

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rk73@sea.plala.or.jp, lamigo@atc.unican.es
  Subject: Re: [HACKERS] please help on query
  In-Reply-To: <20020716011524.3F70.RK73@sea.plala.or.jp>

* 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