Skip site navigation (1) Skip section navigation (2)

Re: NULLS LAST performance

From: Mathieu De Zutter <mathieu(at)dezutter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: NULLS LAST performance
Date: 2011-02-24 09:47:07
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On Wed, Feb 23, 2011 at 10:37 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> > you can always do this:
> > create index performance_creation_date_desc_idx on
> > performance(creation_date desc nulls last);
> > which will index optimize your sql.  Interesting that 'null last'
> > fools disallows index usage even when the index was created with
> > nullls last as the default.
> The problem is that his query needs to scan the index in DESC order,
> which means it's effectively NULLS FIRST, which doesn't match the
> requested sort order.

Merlin, Tom,

Thanks for explaining the behavior!

Any chance that the planner could get smarter about this? In my naive view,
it would just be telling the planner that it can disregard "NULLS" when
searching for an index, in case the column is known to be NOT NULL.

Kind regards,

In response to


pgsql-performance by date

Next:From: GnanakumarDate: 2011-02-24 09:52:38
Subject: Function execution consuming lot of memory and eventually making server unresponsive
Previous:From: Pierre CDate: 2011-02-24 08:22:53
Subject: Re: performance issue in the fields.

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group