Re: [HACKERS] indexes and floats

From: Brook Milligan <brook(at)trillium(dot)NMSU(dot)Edu>
To: maillist(at)candle(dot)pha(dot)pa(dot)us
Cc: vadim(at)krs(dot)ru, lockhart(at)alumni(dot)caltech(dot)edu, tgl(at)sss(dot)pgh(dot)pa(dot)us, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] indexes and floats
Date: 1998-08-06 18:42:12
Message-ID: 199808061842.MAA02106@trillium.nmsu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Sorry, but maybe it would be better to add new attribute
> to pg_proc (and change CREATE FUNCTION syntax) to let
> parser know does result of function call on constants depend
> on execution time or not. This would be much better just
> execute function in parser and replace function with
> constant.
> Currently, only random(), now() and SPI-functions should be
> replaced by PARAM_EXEC, all others could be evaluated by parser.

I see. We have pg_proc.proiscachable. This looks like a good
candidate, and is not used for anything currently. Maybe rename it to
something clearer.

Wouldn't the concept of VOLATILE be relevant here (ala the same
keyword in C and C++)? In those languages the keyword influences the
nature of optimizations that can be done, which seems to be the
problems involved here. We could have a function bool
pg_proc.is_volatile() to determine whether or not the result of the
function call can be determined from its arguments. If so and the
arguments are constants, the function could be evaluated once in the
parser; otherwise, it would need to be evaluated for each tuple.

The current situation, I presume, corresponds with all functions being
VOLATILE and hence evaluated many times. We could 1) add new syntax
for declaring user-defined functions to optionally include VOLATILE
(and/or NONVOLATILE; default being VOLATILE in the absense of a
keyword to maintain compatibility and to be safe), 2) have the
is_volatile() function return appropriate values for all "standard"
functions defined in the system, and 3) include handling of the
distinction in the parser.

Cheers,
Brook

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dr. Michael Meskes 1998-08-06 20:11:11 Re: [HACKERS] Declare Cursor question again
Previous Message Peter T Mount 1998-08-06 17:42:38 Re: [HACKERS] Large objects names