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

Re: Why does a simple query not use an obvious index?

From: "Steinar H(dot) Gunderson" <sgunderson(at)bigfoot(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Why does a simple query not use an obvious index?
Date: 2004-08-30 16:02:28
Message-ID: 20040830160228.GB16847@uio.no (view raw or flat)
Thread:
Lists: pgsql-performance
On Sun, Aug 29, 2004 at 06:03:43PM -0400, Tom Lane wrote:
> The expression "now() - something" is not a constant, so the planner
> is faced with "timestampfield > unknownvalue".  Its default assumption
> about the number of rows that will match is much too high to make an
> indexscan look profitable (from memory, I think it guesses that about
> a third of the table will match...).

Out of curiosity, does the subselect query I presented earlier in the thread
count as "a constant"? It gives the correct query plan, but this could of
course just be correct by accident...

/* Steinar */
-- 
Homepage: http://www.sesse.net/

In response to

Responses

pgsql-performance by date

Next:From: Tom LaneDate: 2004-08-30 16:47:23
Subject: Re: Why does a simple query not use an obvious index?
Previous:From: Greg StarkDate: 2004-08-30 15:41:05
Subject: Re: Why does a simple query not use an obvious index?

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