Re: Inoptimal query plan for max() and multicolumn index

From: Gaetano Mendola <mendola(at)gmail(dot)com>
To: Vladimir Kulev <me(at)lightoze(dot)net>
Subject: Re: Inoptimal query plan for max() and multicolumn index
Date: 2011-07-15 07:14:45
Message-ID: 4E1FE8E5.5000408@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On 20/06/2011 07:35, Vladimir Kulev wrote:

> But this does not work:
> # explain analyze select max(timestamp) from sms where number in
> ('5502712','5802693','5801981');

Try to rewrite that query this way:

explain analyze select timestamp from sms where number in
('5502712','5802693','5801981') order by timestamp desc limit 1;

Regards
Gaetano Mendola

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message jesper 2011-07-15 08:22:59 Re: Hardware advice for scalable warehouse db
Previous Message Gaetano Mendola 2011-07-15 07:14:33 Re: Inoptimal query plan for max() and multicolumn index