Re: Any form of connection-level "session variable" ? - Mailing list pgsql-general

From Tom Lane
Subject Re: Any form of connection-level "session variable" ?
Date
Msg-id 24830.1167940139@sss.pgh.pa.us
Whole thread Raw
In response to Re: Any form of connection-level "session variable" ?  (John McCawley <nospam@hardgeus.com>)
Responses Re: Any form of connection-level "session variable" ?
List pgsql-general
John McCawley <nospam@hardgeus.com> writes:
> I think I got it:
> CREATE FUNCTION new_get_emp_id() RETURNS INTEGER AS $$ select emp_id
> from secureview.tbl_employee where username = (SELECT current_user) $$
> LANGUAGE SQL IMMUTABLE;
> I made the function immutable so it only calls it once, therefore no
> longer requiring a call per-row.

Since it's obviously *not* immutable, this will come back to bite you
sooner or later (probably sooner).  Labeling it STABLE would be
reasonable, although I'm not certain how much that helps you.  Do you
have indexes on the columns it's being compared to?

            regards, tom lane

pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: database design and refactoring
Next
From: Erik Jones
Date:
Subject: Re: Any form of connection-level "session variable" ?