Re: Inoptimal query plan for max() and multicolumn index - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Inoptimal query plan for max() and multicolumn index
Date
Msg-id 4DFF23CC020000250003E994@gw.wicourts.gov
Whole thread Raw
In response to Inoptimal query plan for max() and multicolumn index  (Vladimir Kulev <me@lightoze.net>)
Responses Re: Inoptimal query plan for max() and multicolumn index
List pgsql-performance
Vladimir Kulev <me@lightoze.net> wrote:

> # explain analyze select max(timestamp) from sms where number in
> ('5502712','5802693','5801981');

> According to planner cost estimations - it has enough data to
> understand that it is better to aggregate maximum from three
> subqueries. I suppose it's not a bug but not implemented feature

Yeah, you're hoping for an optimization which hasn't been
implemented.

I expect you're hoping for a plan similar to what this gives you?:

explain analyze select greatest(
  (select max(timestamp) from sms where number = '5502712'),
  (select max(timestamp) from sms where number = '5802693'),
  (select max(timestamp) from sms where number = '5801981'));

-Kevin

pgsql-performance by date:

Previous
From: Claudio Freire
Date:
Subject: Re: how to know slowly query in lock postgre
Next
From: Sushant Sinha
Date:
Subject: sequential scan unduly favored over text search gin index