sql - Oracle checking for existence of rows in a large table -


trying find whether id2 used in table x. easiest way use 'count':

select count(*) x id1 = :1 , id2 = :2 ;

if x large table containing on 90,00,000 data, above query has severe performance impact. there alternative better performance?

note: both column have indexing in table x.

if use:

select count(*)   x  id1 = :1 ,        id2 = :2 ,        rownum = 1; 

then 0 if no rows not found, , 1 if single row found.

the query stop executing when finds first row, , not have deal no_data_found exceptions if no row found.

you composite index on both columns this, combining index may not efficient. if 1 of predicates selective index combine can efficiently skipped , table accessed check other column's value.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -