Re: EXPLAIN detail - Mailing list pgsql-performance

From Craig Ringer
Subject Re: EXPLAIN detail
Date
Msg-id 47FCA58D.5070904@postnewspapers.com.au
Whole thread Raw
In response to Re: EXPLAIN detail  ("Luigi N. Puleio" <npuleio@rocketmail.com>)
List 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

pgsql-performance by date:

Previous
From: "Luigi N. Puleio"
Date:
Subject: Re: EXPLAIN detail
Next
From: "Luigi N. Puleio"
Date:
Subject: Re: EXPLAIN detail