Many scalar functions return values that are independent of the row being processed because the input arguments are literals. For example, a function such as today() defined as returning today’s day can be marked as a constant function. This helps in the following ways:
• The user defined function implementing the function is only called once at the beginning of the query.
• The function can be treated as a literal value where optimization is concerned. For example, in a query of the form:
SELECT * FROM events WHERE event_day = today()
the IP gets a restriction on event_day and its value is that of today (for example, ‘Monday’).