Oracle Scratchpad

February 11, 2024

Object_id

Filed under: Infrastructure,Oracle — Jonathan Lewis @ 6:23 pm GMT Feb 11,2024

This is a note that will probably be of no practical use to anyone – but someone presented me with the question so I thought I’d publish the answer I gave:

Do you know how object ID is assigned? It doesn’t look as if a sequence is used

I’m fairly sure the mechanism has changed over versions. (Including an enhancement in 23c where the object number of a dropped (and purged) object can be reused.)

I don’t really know what Oracle does, but I do know that there is an object in obj$ called “_NEXT_OBJECT” and Oracle uses that as a control mechanism for the dataobj# and obj# (data_object_id and object_id) in some way. I think Oracle uses the row a bit like the row used by a sequence in seq$ – the dataobj# is bumped by a small value (seems to be 5) each time it is reached (cp. seq$.highwater for a sequence) and it’s possible that the obj# is used to record the instance number of the instance that bumped it. The instance then (I think) has a small cache of obj# values it can use before it has to read and update the “_NEXT_OBJECT” row again.

Footnote.

You might note that this description means that it is the dataobj# that actually drives the generation of a new obj# / object_id. You can demonstrate this most easily (if you have sole access to the database) by:

  • creating a table,
  • checking its object_id and data_object_id (which will match),
  • moving it a couple of time (which will increment the data_object_id – and only the data_object_id – each time),
  • creating another table.

The second table will have an object_id that is one more than the current data_object_id of the first table.

6 Comments »

  1. Hi Jonathan,

    the dataobj# is bumped by a small value (seems to be 5)

    Yes, 5 is the default value. The corresponding parameter is “_object_number_cache_size”.

    I tried to figure out how to post source code with the new WordPress interface, albeit without success. I used to use the code tag in square brackets which apparently does not work anymore.

    Here is sample code in which I changed _object_number_cache_size to 10 to demonstrate that _NEXT_OBJECT also got increased by this value: https://gist.github.com/mvelikikh/5aa5ab30b70152b162c3dc4dcdf46460

    Thanks,Mikhail.

    Comment by Mikhail Velikikh — February 12, 2024 @ 11:50 am GMT Feb 12,2024 | Reply

    • Mikhail,

      Thanks for the confirmation and extra information.

      FYI – the current mechanism for embedding code is to use “sourcecode” rather than “code” in square brackets (and /sourcecode to end the embedded code).

      Regards

      Jonathan Lewis

      Comment by Jonathan Lewis — February 12, 2024 @ 5:19 pm GMT Feb 12,2024 | Reply

  2. This mechanism is really very complicated. When we moved from 19.5 to 19.13, we hit following bug: Bug 33961486 – ORA-00001: UNIQUE CONSTRAINT (SYS.I_OBJ1) VIOLATED. It occured mainly during TTS import to database (where we perform it on daily basis). The issue was connected to backport of row cache mutexes optimisation (oracle replaced row cache latches by mutexes in some cases) to 19c. As row cache is linked heavily, there were some performance issues with row cache hot objects. So oracle introduced mechanism to manage row cache hot mutexes to create hot copies (silimiar to LC which can be managed by dbms_shared_pool.markhot). That hot copies were a bug trigger, so we were forced to disable them in 19.13. by setting _bug33046179_kqr_hot_copy_sleep_limit=0. The bug is still unresolved, however oracle support responded that nobody had observed that bug from 19.17 onwards.

    Comment by Anonymous — February 12, 2024 @ 12:24 pm GMT Feb 12,2024 | Reply

    • Thanks for the extra information – starting at Doc ID 33046179.8 and following the chain of documents through MOS made for a very interesting read. Doc ID 31135517.8 was a particularly nice note, and Doc ID 31933451.8 added a useful “threat-warning”.

      Regards

      Jonathan Lewis

      Comment by Jonathan Lewis — February 12, 2024 @ 5:27 pm GMT Feb 12,2024 | Reply


RSS feed for comments on this post. TrackBack URI

Comments and related questions are welcome.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Website Powered by WordPress.com.