sql - ORACLE NOT NULL IN WHERE CLAUSE WITH NVL OPERATION -
i want know query faster.
ex:1
select comm emp comm not null;
ex:2
select comm emp nvl(comm,'0') not null;
please consider emp table contains hundreds of thousands of records.
instead of asking hypothetical question should run benchmarks on actual data. here observations:
your queries different things. first query selects records comm not null. second query selects records.
in both cases 2 full table scans: " lakhs of records." makes no difference. however, given have same projection , no sort clause execution time same.
except:
- the time render output different, because second result set may larger first.
- if there index on
emp(comm)
first result use full fast index scan, because you're selectingcomm
there's no need touch table. index read faster because normal oracle indexes don't index nulls. - even if there's function-based index on
emp(nvl(comm))
second query still execute full table scan, because selectcomm
in projection query still needs read table.
Comments
Post a Comment