Re: Slow plan for MAX/MIN or LIMIT 1? - Mailing list pgsql-performance

From Claudio Freire
Subject Re: Slow plan for MAX/MIN or LIMIT 1?
Date
Msg-id CAGTBQpa=5xrwb00gHmsxEzt6bTktPe5sguK+9yuQccGPUfBnCQ@mail.gmail.com
Whole thread Raw
In response to Re: Slow plan for MAX/MIN or LIMIT 1?  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-performance
On Wed, Sep 25, 2013 at 12:54 PM, Merlin Moncure <mmoncure@gmail.com> wrote:
>> I was thinking an index over:
>>
>> (event, date_trunc('day', insert_time), log_id)
>>
>> And the query like
>>
>> SELECT min(log_id) FROM event_log
>> WHERE event='S-Create' AND
>> date_trunc('day',insert_time) = '2013-09-15'
>>
>>
>> That's a regular simple range scan over the index.
>
> *) date_trunc has same problems as ::date: it is stable expression
> only for timestamptz.  also, the index will be bigger since you're
> still indexing timestamp


Ah, yes, good point.


pgsql-performance by date:

Previous
From: "Sam Wong"
Date:
Subject: Re: Slow plan for MAX/MIN or LIMIT 1?
Next
From: Josh Berkus
Date:
Subject: Re: Why is n_distinct always -1 for range types?