Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > Re: using calcu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 9 Topic 3533 of 3799
Post > Topic >>

Re: using calculated column in where-clause

by scott.marlowe@[EMAIL PROTECTED] ("Scott Marlowe") Jun 18, 2008 at 02:47 PM

On Wed, Jun 18, 2008 at 1:35 PM, Fernando Hevia <fhevia@[EMAIL PROTECTED]
>
wrote:
>
>> -----Mensaje original-----
>> De: pgsql-sql-owner@[EMAIL PROTECTED]
>> [mailto:pgsql-sql-owner@[EMAIL PROTECTED]
 En nombre de Patrick
>> Scharrenberg
>> Enviado el: Martes, 17 de Junio de 2008 17:46
>> Para: pgsql-sql@[EMAIL PROTECTED]
>> Asunto: [SQL] using calculated column in where-clause
>>
>> Hi!
>>
>> I'd like to do some calculation with values from the table,
>> show them a new column and use the values in a where-clause.
>>
>> Something like this
>> select a, b , a*b as c from ta where c=2;
>>
>> But postgresql complains, that column "c" does not exist.
>>
>> Do I have to repeat the calculation (which might be even more complex
>> :-) ) in the "where"-clause, or is there a better way?
>>
>
> For complex calculations I have obtained better performance using nested
> queries. For example:
>
> select a, b, c select
>   ( select a, b, a*b as c from ta) subquery1
> where c = 2;
>
> This nesting is probably overhead in such a simple case as this, but in
more
> complex ones and specially with volatile functions it will provide an
> improvement.

I was under the impresion from previous discussions that the query
planner flattened these out to be the same query.  Do you get
different query plans when you re-arrange this way?

-- 
Sent via pgsql-sql mailing list (pgsql-sql@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
 




 9 Posts in Topic:
using calculated column in where-clause
pittipatti@[EMAIL PROTECT  2008-06-17 22:46:08 
Re: using calculated column in where-clause
akretschmer@[EMAIL PROTEC  2008-06-17 23:10:41 
Re: using calculated column in where-clause
pittipatti@[EMAIL PROTECT  2008-06-18 07:31:32 
Re: using calculated column in where-clause
scott.marlowe@[EMAIL PROT  2008-06-17 15:15:13 
Re: using calculated column in where-clause
fhevia@[EMAIL PROTECTED]   2008-06-18 16:35:48 
Re: using calculated column in where-clause
scott.marlowe@[EMAIL PROT  2008-06-18 14:47:08 
Re: using calculated column in where-clause
fhevia@[EMAIL PROTECTED]   2008-06-19 15:23:48 
Re: using calculated column in where-clause
fhevia@[EMAIL PROTECTED]   2008-06-19 15:32:53 
Re: using calculated column in where-clause
tgl@[EMAIL PROTECTED] (T  2008-06-19 14:38:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 21:35:14 CST 2008.