oracle - Inconsistency in sql query output using OR after WHERE -
i'm doing query on complex db:
select * table1, table2, table3, table4, table5, table6, table7, table8 = b , c = d , e = d , ( (strfldvar = 'broken_arrow' , x = g) or (strfldvar = 'broken_box' , y = g) ) , f = h , = j only works when strfldvar = 'broken_box' , not when strfldvar = 'broken_arrow'. when replace
( (strfldvar = 'broken_arrow' , x = g) or (strfldvar = 'broken_box' , y = g) ) , with either x = g and or y = g and works fine in 2 seperate queries runs that. error message case strfldvar = 'broken_arrow' is:
ora-01013: user requested cancel of current operation
before error message comes computer goes deep thought guess 2 minutes.
what doing wrong here?
f.y.i. looked @ names of fields of of 2 seperate runs , appear idendical. mean scema of output looks same both. i'm not 100% sure same, if matters i.e.
thanks
when strfldvar = 'broken_arrow' , x = g (or if strfldvar not broken_arrow or broken_box), y = g part not evaluated, seems causing query run longer expect - until it's killed you, client or resource limits. suspect that's join condition whichever table y from, end cartesian product.
when strfldvar = 'broken_box' both x = g , y = g evaluated, wouldn't same cartesian product, against either of tables providing x , y.
if deciding table include in query based on flag you'll need redesign this; possibly union of 2 queries, 1 joins x , other on y; or separate queries , decide run; or maybe outer joins. depends on you're trying , data looks like. code have shown generic guess appropriate.
Comments
Post a Comment