Search Postgresql Archives

Re: Need help optimizing this query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 18, 2007, at 16:01 , Michael Glaesemann wrote:

CREATE OR REPLACE FUNCTION one_when(BOOLEAN)
RETURNS INTEGER
LANGUAGE SQL as $_$SELECT value_when($1,1)$_$;

I forgot to add that you can cast booleans to integers, so one_when (expr) is equivalent to expr::int:

# SELECT (true and false)::int, (true or false)::int;
int4 | int4
------+------
    0 |    1
(1 row)

Of course, this rewriting shouldn't affect the performance at all: it should just make it easier for you to read, which does have some value.

Michael Glaesemann
grzm seespotcode net




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux