pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Vladimir Kulev <me@lightoze.net>
To: pgsql-performance@postgresql.org
Subject: Re: Inoptimal query plan for max() and multicolumn index
Date: Mon, 20 Jun 2011 10:41:16 -0500
Message-ID: <4DFF23CC020000250003E994@gw.wicourts.gov> (raw)
In-Reply-To: <BANLkTimsNMhnAHk6Wz7gARfdkTmz2QKJ7g@mail.gmail.com>
References: <BANLkTimsNMhnAHk6Wz7gARfdkTmz2QKJ7g@mail.gmail.com>

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



view thread (6+ messages)  latest in thread

Message-ID: <4DFF23CC020000250003E994@gw.wicourts.gov>
Permalink:  ../4DFF23CC020000250003E994@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4DFF23CC020000250003E994@gw.wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, me@lightoze.net
  Subject: Re: Inoptimal query plan for max() and multicolumn index
  In-Reply-To: <4DFF23CC020000250003E994@gw.wicourts.gov>
  References: <BANLkTimsNMhnAHk6Wz7gARfdkTmz2QKJ7g@mail.gmail.com> <4DFF23CC020000250003E994@gw.wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox