Re: min/max performance inequality.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pawel Veselov <pawel(dot)veselov(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: min/max performance inequality.
Date: 2015-01-07 23:35:51
Message-ID: 1018.1420673751@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pawel Veselov <pawel(dot)veselov(at)gmail(dot)com> writes:
> I was wondering how come there is such a drastic difference between finding
> max and min. Seems like "index scan backwards" is really bad...

It's probably an artifact of your data distribution, ie, the "blockid =
4814" condition is skipping lots of rows at one end of the index but few
or none at the other.

If you're concerned about the performance of this type of query, an index
on (blockid, rowdate) would work a lot better than the ones you've
provided.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pawel Veselov 2015-01-08 00:00:07 Re: min/max performance inequality.
Previous Message Jeff Janes 2015-01-07 23:34:49 Re: min/max performance inequality.