Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Ali.

Asked: January 17, 2017 - 10:43 am UTC

Last updated: January 19, 2017 - 1:04 am UTC

Version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0

Viewed 1000+ times

You Asked

Hello,

I am refactoring and existing dB. No primary key and indexes were used.

There will be surrogate numeric (integer) primary keys on new tables with foreign key constraints...

I was wondering what is the best numeric format for performances?

By default, I see PK as NUMBER (no precision).

Shall I add a precision for better performance on Indexes? If yes, which one?

I saw on some posts Number(38,0) or even Number (9,0) to match INT32...

Thanks in advance for your answers,
Ali

PS: you may point to an article/post on performances and indexes in oracle for my knowledge ;-)

and Connor said...

I would definitely use NUMBER(n) because otherwise, "123.546223" becomes a valid primary key. In *theory* you wouldn't care, but given that 99% of the world's surrogate keys are probably an integer or guid, there will probably be plenty of developers assuming this and therefore getting in code trouble if its not.


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

More on Oracle indexes

Rajeshwaran, Jeyabal, January 18, 2017 - 11:11 am UTC

you may point to an article/post on performances and indexes in oracle for my knowledge ;-)

To learn all about indexes in Oracle database, then richard's blog is the best place to go.

https://richardfoote.wordpress.com/
Connor McDonald
January 19, 2017 - 1:04 am UTC

I agree 100%