oracle - Optimize where clause SQL -
i trying figure out way optimize below sql query:
select * some_table (col1 = 123 , col2 = 'abc') or (col1 = 234 , col2 = 'cdf') or (col1 = 755 , col2 = 'cvd') ---> have around 2000 'or' statements in single query.
currently query takes long time execute, there anyway make query run faster?
- create lookup table
create table lookup (col1 int, col2 varchar(3), primary key(col1, col2), key(col2)) organization index
or whatever fits needs - make sure have indexes on original table (col1 , col2)
- populate lookup table 2000 combinations
now query
select mytable.* mytable inner join lookup on mytable.col1=lookup.col1 , mytable.col2=lookup.col2
Comments
Post a Comment