How rowid(s) are being assigned for newly creating records?

Posted by ithrees.ai on 13-Sep-2011 06:40

Hi everyone,

Can someone explain me on how rowid is being assigned for a new record...?

Does it get the rowid from a increamental sequence or use any rowid that is emptied because of a deletion...?

Orelse is there anyway to configure that manually in the Prograss Database..?

Hope you have the answer.. and thanks in advance..

Regards,

Ithrees.

All Replies

Posted by Admin on 13-Sep-2011 06:46

The ROWID represents the physical location of the record in the database. It's built using the block number the record is located in and the record number within that block.

There is no way to influence that (other by changing the possible number of records per block). And as such ROWID's can be reused after a record has been deleted - even by data of a different table.

What are you up to? Maybe you'd better use your own identifier, like a GUID?

Posted by Admin on 13-Sep-2011 06:48

What are you up to? Maybe you'd better use your own identifier, like a GUID?

One more note on that: You should never assume anything about the ROWID value. After a dump and load of the database, thet ROWID will be in 99.999999% of all cases a different one for the same record. It's the most technical "key" you can think of. Don't use it's value in an application at all.

Posted by Tim Kuehn on 13-Sep-2011 08:16

also, ROWID's aren't unique in a database, only in a storage area.

Posted by Admin on 13-Sep-2011 08:21

also, ROWID's aren't unique in a database, only in a storage area.

Yeah - I missed that. But they are unique per table (at least at a single point in time).

Posted by gus on 13-Sep-2011 12:16

And in OpenEdge 11, rowid's will not be unique per table either, if the database is multi-tenant. The trend for the past 12 years has been that they have become less and less unique.

Note also that though the rowid of a record is constant for the life of the record, once it has been deleted, then the same rowid can be used again for a completely different record.

Posted by ithrees.ai on 14-Sep-2011 00:04

Thanks for your response and they are very useful to me...

and If you can explain this... please...

I have a system that creates and deletes intermediate database records in runtime (like a batch process).
System creates temporary records so they can be used in process of a certain transaction and will delete when the transaction is over.
System is working fine.
But the confusion is, I have installed this program in two different machines and they are running with its own local databases.
When I run the program,
in one database the ROWID(s) values for the newly creating intermediate record are in an incremental form.
But in the other one they are having earlier deleted record’s ROWID(s) values.
How this could happen with the same system…?
Thanks and Regards,
Ithrees.

Posted by gus on 14-Sep-2011 08:48

That happens because the databases are not the same - they contain different data and the free space is in different places. The rowid that is assigned to a new row depends on the location that the database table space allocator decides to put the row. It decides where to put things based on a variety of factors: how big the new row is, what kind of storage area it is going into, what the configuration parameters for the area are, how much free space there is, and where it is, and so forth.

For practical purposes, you should consider rowids to be random numbers. You can depend on a row's rowid to remain constant until you delete it but not on /anything/ else about it. Definitely not on how they are assigned because that has changed a lot over the years and is likely to change again in the future.

Posted by ithrees.ai on 14-Sep-2011 22:39

Thank you very much guys...

This thread is closed