Re: [SQL] How does the planner treat a table function.

2005-03-16 Thread KÖPFERL Robert
If you are interested in performance things, you may use the EXPLAIN command: explain select * from "GetLanguages"() where "Id" > 44 vs. explain select * from "Languages" where "Id">44; However the explain stops at the point a function is invoked. This may mean that (as you asked) a select ove

[SQL] PGCrypto with Integers and DATE types -- how to?

2005-03-16 Thread Moran.Michael
Hello, How do you encrypt() & decrypt() data of types INT4 or DATE? The PGCrypto methods encrypt() and decrypt() each take BYTEA as input: i.e., encrypt( data::bytea, key::bytea, type::text) decrypt( data::bytea, key::bytea, type::text) So how do you convert INT4 and DATE data into BYTE

Re: [SQL] How to force subquery scan?

2005-03-16 Thread Tom Lane
"Tambet Matiisen" <[EMAIL PROTECTED]> writes: > It seems that subquery scan is only used, when the query can not be > translated into single flat query. Which is mostly good, I assume. The planner thinks so anyway ;-) If you're desperate you can put in an optimization fence, for instance LIMIT or

Re: [SQL] Parameterized views proposition

2005-03-16 Thread Tambet Matiisen
> > "Tambet Matiisen" <[EMAIL PROTECTED]> writes: > > How tough it would be to implement > > > CREATE VIEW xxx PARAMETERS (yyy) AS zzz; > > > as > > > CREATE TYPE xxx; > > CREATE FUNCTION xxx(yyy) RETURNING SETOF xxx LANGUAGE sql AS 'zzz'; > > What's the point? It'd be nonstandard anyway,

Re: [SQL] How to force subquery scan?

2005-03-16 Thread Tambet Matiisen
... > > Does this do better: > > SELECT > prodid, > avg(prodcost) as average_cost, > sum(prodcost * salesamount) as cost_total > FROM ( > SELECT > p.product_id as prodid, > product_cost(s.product_id, s.date) as prodcost, > s.amount as salesamount > FROM products p > LEFT

Re: [SQL] Generic Function

2005-03-16 Thread PFC
Look in the plpgsql docs on EXECUTE. But for something that simple, why don't you just generate a query ? ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail comm

Re: [SQL] Generic Function

2005-03-16 Thread lucas
Oh sorry. I was not clearly. I've wanted to create a function that suport to select a "parameter variable" table. Like: return 'select * from $1'. The Postgresql does not suport this sql function becouse the $1 variable is considerate as a table... the Postgresql return an error like: The table "$