Constant propagation and similar issues - Mailing list pgsql-hackers

From Jules Bean
Subject Constant propagation and similar issues
Date
Msg-id 20000911132612.C4579@grommit.office.vi.net
Whole thread Raw
Responses Re: Constant propagation and similar issues
List pgsql-hackers
I'm sure your aware of these limitations, but I'd thought I'd mention
them just in case, and to see if you have plans to sort them out:

I have a query of the form:

SELECT * FROM .... WHERE (now()-date1) > 'interval 1 day';

..i.e. all rows 'older' than 1 day.  This could be efficiently
processed using the index on date1, but sadly pg doesn't know this ;-(
This transforms an operation which should be O(1) to O(rows)....

More worryingly, when I investigated the above, I find it doesn't even
use the index for

SELECT * FROM .... 
WHERE date1 > '2000-09-11 00:00:00'::datetime - '1 hour'::interval;

...so it doesn't realise that constant-constant is constant,
notwithstanding the more complex issues that now() is pseudo-constant.

This could be fixed by constant folding, I guess; any plans for that?

Jules


pgsql-hackers by date:

Previous
From: "Valter Mazzola"
Date:
Subject: Re: AW: Scalability, Clustering
Next
From: Palle Girgensohn
Date:
Subject: Re: [SQL] need asap: bg_BG locale for FreeBSD