Subject | performance |
---|---|
Author | Sergio H. Gonzalez |
Post date | 2008-12-23T20:45:29Z |
Hello, I'm using FB2.1
I have a SELECT with a some ORs depending on some parameters, in this form:
SELECT * FROM TABLE_1 WHERE
(FIELD1 = 'A' and :par1 = -1) or
(FIELD1 = 'B' and :par2 = -1) or
(FIELD1 = 'C' and :par3 = -1) ... etc
So, with the params I "switch ON/OFF" some filters
What would be better (faster) ? The previous approach or just construct the SQL
statement in the client side with only the filters I need?
Generally speaking: Is a bad practice to construct the SQL on the client side?
Some times it seems to be no other option...
Thanks!
-sergio
I have a SELECT with a some ORs depending on some parameters, in this form:
SELECT * FROM TABLE_1 WHERE
(FIELD1 = 'A' and :par1 = -1) or
(FIELD1 = 'B' and :par2 = -1) or
(FIELD1 = 'C' and :par3 = -1) ... etc
So, with the params I "switch ON/OFF" some filters
What would be better (faster) ? The previous approach or just construct the SQL
statement in the client side with only the filters I need?
Generally speaking: Is a bad practice to construct the SQL on the client side?
Some times it seems to be no other option...
Thanks!
-sergio