Re: EXPLAIN detail

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "Luigi N(dot) Puleio" <npuleio(at)rocketmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: EXPLAIN detail
Date: 2008-04-09 11:16:29
Message-ID: 47FCA58D.5070904@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Luigi N. Puleio wrote:

> SELECT
> (a.column1)::date, MIN(b.column2) - a.column2
> FROM
> table a
> inner join table b
> on ((a.column1)::date = (b.column1)::date amd
> b.column3 = 'b' and (b.column1)::time without time
> zone >= (a.column1)::time without time zone)
> WHERE
> (a.column1)::date = '2008-04-09'
> a.column3 = 'a'
> GROUP BY a.column1
>
> and with this I have to obtain like 3-4 records from
> all those whole 500000 records and with the explain
> analyze I get almost 6 seconds:
>
> Nested Loop (cost=0.00...52140.83 rows=1 width=34)
> (actual time=4311.756...5951.271 rows=1 loops=1)

With all that casting, is it possible that appropriate indexes aren't
being used because your WHERE / ON clauses aren't an exact type match
for the index?

Can you post the full EXPLAIN ANALYZE from the query? This snippet
doesn't even show how records are being looked up.

What about a \d of the table from psql, or at least a summary of the
involved column data types and associated indexes?

--
Craig Ringer

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Luigi N. Puleio 2008-04-09 13:45:59 Re: EXPLAIN detail
Previous Message Luigi N. Puleio 2008-04-09 11:05:54 Re: EXPLAIN detail