Gavin Sherry wrote:
On Wed, 18 Dec 2002, Bruce Momjian wrote:


What exactly can you do with these variables other than SHOW/SET.  Seems
it would be nice if they could be used in queries, like in a special
table like sysvar:

	SELECT sysvar.fsync;

Isn't that just identical to having a table?
Well you can use it in a query:

regression=# select pg_create_user_setting('myvar',17,false);
pg_create_user_setting
------------------------
17
(1 row)

regression=# select typname from pg_type where oid = current_setting('myvar');
typname
---------
bytea
(1 row)

There are at least two differences to this approach vs a table:

1. Main reason is that if a user defined function/contrib module creates a table in my database I consider that too intrusive. I'd prefer not to have metadata tables in my database simply to support a loaded function.

2. It's faster. In some simple tests, I found that getting a setting value via current_setting('myvar') is about 40% faster than getting a value from a one row table, and about 100% faster than an indexed lookup in a larger table (after the table is cached, more than that on the first lookup).

Joe


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to