From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Giorgio Valoti <giorgio_v(at)mac(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Query Plan choice with timestamps |
Date: | 2008-08-07 12:36:18 |
Message-ID: | 489AEC42.5080007@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Giorgio Valoti wrote:
>
> On 07/ago/08, at 10:35, Richard Huxton wrote:
>
>> Giorgio Valoti wrote:
>>> Hi, I have a timestamptz field that I want to use with a query, but I
>>> don’t need the full timestamp resolution, so I’ve created a
>>> day_trunc(timestamptz) immutable function which I’ll use with the
>>> query and with a new index:
>>> logs=> create index test_idx on blackbox (day_trunc(ts));
>>> However, the query plan doesn’t use the index:
>>
>> Does it use it ever? e.g. with
>> SELECT * FROM blackbox WHERE day_trunk(ts) = '...'
>
> It’s used:
[snip]
OK - so the index is working.
If you disable seq-scans before running the query, does it use it then?
SET enable_seqscan = off;
> logs=>explain select count(*) from blackbox group by day_trunc(ts) order
> by day_trunc(ts);
> QUERY PLAN
>
------------------------------------------------------------------------------------------
>
> GroupAggregate (cost=98431.58..119773.92 rows=74226 width=8)
In particular:
1. Is the estimated cost more or less than 119773.92?
2. How does that match the actual time taken?
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | dforums | 2008-08-07 13:30:16 | Re: Plz Heeeelp! performance settings |
Previous Message | Giorgio Valoti | 2008-08-07 12:30:51 | Re: Query Plan choice with timestamps |