row-specific conditions possible?

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

 



Hi,

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 result. 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!

--
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux