Skip site navigation (1) Skip section navigation (2)

row-specific conditions possible?

From: Jörg Kiegeland <kiegeland(at)ikv(dot)de>
To: pgsql-performance(at)postgresql(dot)org
Subject: row-specific conditions possible?
Date: 2009-01-15 10:42:29
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance

I want to store a boolean SQL condition in a column "condition_column" 
of my table "myTable".
This condition refers to other columns of the same table and shall use 
one parameter, e.g. "column1=4 AND colume2+column3=param".
Every row has a different condition in general..

So my query on the table should look like "SELECT * FROM myTable WHERE 
anotherCondition AND EXECUTE condition_column(7)"
In this example, the concrete argument is "7".
However EXECUTE can only be used for prepared statements, and I dont 
know how to prepare a statement within one single SQL query.
Does anybody know?

Our current solution is to execute "SELECT * FROM myTable WHERE 
anotherCondition" where "anotherCondition" selects ~30% of the table,
and we evaluate the row-specific condition on client-side by our own 
condition-evaluator, so that we finally have ~1% from the whole table as 
This however fetches 1/3 of the table over a remote JDBC connection. Its 
clear that a server-side evaluation would also scan 1/3 of the table,
however only the final result would be transfered to the client.

Thanks for any help!


pgsql-performance by date

Next:From: A. KretschmerDate: 2009-01-15 11:06:01
Subject: Re: row-specific conditions possible?
Previous:From: Euler Taveira de OliveiraDate: 2009-01-14 13:39:51
Subject: Re: index

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group