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:

  1. the time render output different, because second result set may larger first.
  2. if there index on emp(comm) first result use full fast index scan, because you're selecting comm there's no need touch table. index read faster because normal oracle indexes don't index nulls.
  3. even if there's function-based index on emp(nvl(comm)) second query still execute full table scan, because select comm in projection query still needs read table.

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -