Constant propagation and similar issues

From: Jules Bean <jules(at)jellybean(dot)co(dot)uk>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Constant propagation and similar issues
Date: 2000-09-11 12:26:13
Message-ID: 20000911132612.C4579@grommit.office.vi.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Valter Mazzola 2000-09-11 13:33:26 Re: AW: Scalability, Clustering
Previous Message Martin A. Marques 2000-09-11 11:14:24 problems with GRANT on Solaris 8