Re: On using "date 'XXX' + interval 'XXX'" vs "date 'XXX'" - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: On using "date 'XXX' + interval 'XXX'" vs "date 'XXX'"
Date
Msg-id 3CE922B2.B3AE8D95@fourpalms.org
Whole thread Raw
In response to On using "date 'XXX' + interval 'XXX'" vs "date 'XXX'"  (Jon Lapham <lapham@extracta.com.br>)
List pgsql-general
> > Try coercing the sum result back to a date.
...
> PS: Is this optimizable?  (ie: have the coersion be implicit in
> situations like this).  It sure seems like it is a good candidate...

Not at the parser or optimizer level. You *could* have had hours,
minutes, or seconds in that interval value you specified, in which case
you would be truncating to get back to date. We'd need more
infrastructure to somehow know how to optimize something like that.

Or, we could split the INTERVAL type into the (ugh) bunch-o-types
envisioned by the SQL standard. YEAR, MONTH, YEAR TO MONTH, and DAY
intervals could be converted directly to dates rather than timestamps.
This would allow the optimizer to know what the output range would be,
whereas now the range info is just used for input and output (and is
usually a don't-care internally since the other fields are zeros).

                  - Thomas

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Referential Integrity.
Next
From: Patrick Welche
Date:
Subject: Re: Row Locking