currently we have a column with only integer values declared as NUMBER. At the same time it is our (only) index. I wonder if it would make a difference in performance if you declare the index as INTEGER? Or is Oracle smart enough to see that it is an integer? Thank you very much.
Share
No, it won’t.
Taking Florin’s test tables, you can set up a small test harness that runs each query hundreds of times and averages the elapsed time. In my case, I ran both queries 500 times each.
Sometimes, the
NUMBERversion will run slightly faster (1.232 hundredths of a second vs 1.284 hundredths of a second).If you immediately run the same code block again, however, you’re just as likely to see the reverse where the integer version runs slightly faster.
Realistically, where you’re trying to measure differences in milliseconds or fractions of milliseconds, you’re well into the realm where system noise is going to come into play. Even though my machine is “idle” other than the test I’m running, there are thousands of reasons why the system might add an extra millisecond or two to an elapsed time to deal with some interrupt or to run some background thread that does something for the operating system.
This result makes sense when you consider that
INTEGERis just a synonym forNUMBER(38)Update:
Even using a NUMBER(6) (note that the
INSERThas to be changed to load only 999,999 rows rather than 1 million), there is no changeCreate the table
Run the script. Note that there are no significant differences across any of the four runs and (by chance) in none of the four cases is the
NUMBER(6)table the most efficient.