Rowid Recid

Posted by Admin on 03-Mar-2011 13:19

whats the difference between rowid and recid ?

All Replies

Posted by Admin on 03-Mar-2011 15:24

whats the difference between rowid and recid ?

Do you have access to the product documentation?

RECID: Returns the unique internal identifier of the database record currently associated with the record buffer you name. This internal identifier has the data type RECID, a four-byte value that is supported by OpenEdge databases and some non-OpenEdge DataServers.

This function is supported for backward compatibility. For most applications, use the ROWID function, instead. For more information, see the ROWID function reference entry.

Returns the unique internal identifier of the database record currently associated with the record buffer you name. This internal identifier has the data type ROWID, which is supported for OpenEdge and all other DataServer databases.

The ROWID data type is a variable-length byte string capable of representing a record identifier for any DataServer database.

Posted by Thomas Mercer-Hursh on 04-Mar-2011 12:30

Anyone who has access to this forum has access to the product documentation ... using it may be another issue!

Posted by Admin on 04-Mar-2011 13:44

Anyone who has access to this forum has access to the product documentation ... using it may be another issue!

But wouldn't that be too simple?

Posted by cverbiest on 22-Dec-2011 03:07

DISCLAIMER : WHAT FOLLOWS IS PROBABLY UNSUPPORTED

For OpenEdge databases the string representation of a rowid is the hex representation of the recid.

Following (.Net only) methods converts a recid to rowid. Unfortunately OpenEdge does not provide a supported built-in method to do this.

This works in OpenEdge 10.2B, the number of digits may be different for other versions, I have not checked this.

    method public static rowid ToRowid(input iRecid as recid):
        return ToRowid(int64(iRecid)).
    end method.


    method public static rowid ToRowid(input iRecid as int64):

        define variable HexValue as character no-undo.

        hexValue = lc(System.Convert:ToString(iRecid,16)).
        hexValue = "0x" + fill("0", 16 - length(HexValue)) + HexValue.

        return to-rowid(HexValue).

    end method.

The .Net requirement is easily removed but I needed it only in a .Net context.

Posted by jmls on 22-Dec-2011 03:14

mmmmmm, I seem to remember that RECID are not guaranteed to be unique

within a database with type II storage area, but rowids are

Database gurus would be better placed to comment, but be very very

careful about recids

On 22 December 2011 09:07, Carl Verbiest

Posted by cverbiest on 22-Dec-2011 04:53

Hi Julian,

According to the manual both are unique per area, not within a database. The same value can appear in every area.

RECID A RECID is a unique internal identifier for a record within a single database storage area.
Note: RECID is supported mainly for backward compatibility. For most applications, use ROWID instead.
ROWID A ROWID is a unique internal identifier for a record within a single database storage area.

Posted by gus on 22-Dec-2011 08:25

A recid is an encoded form of the storage location of a database record.

A rowid is an encoded form of the storage location of a database record.

At one time in the past, recids were 32 bits long and could be cast into integers and vice versa. Now they can be up to 64 bits long. So can integers.

rowids were a variable length bit string from their inception and cannot be cast into integers. Plans changed after that. since we made recids capable of being up to 64 bits long, except for the part about casting to integer, for OpenEdge databases, recid and rowid are now the exact same thing.

Message was edited by: Gus Bjorklund

Posted by gus on 22-Dec-2011 08:43

they are more or less interchangeable except for the conversion to/from integers.

At one time, a recid was unique within an entire database.

In version 9.0 through 10.2, they are unique only within a data storage area.

From version 11.0 on, in multi-tenant tables they are unique only within a single tenant's table data partition. Two tenants can each have the same rowid for their records in a table.

A record's recid/rowid is constant for the life of the record. It is assigned when a record is created and a storage location for it is chosen. It will not change when the record is updated. It /will/ change if the record is deleted and then created again.

Although they are not, you should behave as though recid/rowids are randomly generated values.

Posted by gus on 22-Dec-2011 08:44

as of 10.1B, recid/rowids are not 4 bytes for the OpenEdge RDBMS. They are variable lenght and can be up to 8 bytes long now.

Posted by jmls on 22-Dec-2011 08:49

see. I told you that the db guys know more than I did

On 22 December 2011 14:25, Gus Bjorklund

Posted by ke@iap.de on 02-Oct-2018 02:46

Hello Gus,

you stated "A record's recid/rowid is constant for the life of the record". I remember in former times, when a record grows, it may be relocated. Will this not change recid/rowid? Or is this now different (split instead of relocation)?

I assume a DB without partitioning and Multi-Tenancy... :)

kind regards

Klaus

Posted by Mike Fechner on 02-Oct-2018 02:52

In the meantime horizontal table partitioning has been implemented. When a record’s (key) value is value is changed causing the record to be moved to a different partition will also result in a new rowid/recid for that record.

Posted by ke@iap.de on 02-Oct-2018 02:56

Mike, I know :)

That's why I added  that I assume no partitioning :)

So short and hopefully clear question is: Is there relocation of records or not. And if yes, how can the rowid be stable.

Posted by George Potemkin on 02-Oct-2018 02:57

> I remember in former times, when a record grows, it may be relocated.

The first fragment of record always keeps the same recid.

Posted by ke@iap.de on 02-Oct-2018 03:28

Thanks :)

Posted by Rob Fitzpatrick on 02-Oct-2018 06:23

> A record's recid/rowid is constant for the life of the record

Klaus, the DBA could also decide to tablemove the table.  That would almost certainly change rowids/recids as well.  Best not to assume they are constant.

Posted by 2087 on 02-Oct-2018 06:37

And your Klaus could even do a dump and load of all the data.

Posted by gus bjorklund on 03-Oct-2018 13:02

yes, Klaus, a rowid/recid is constant for the "life of a record”. This means from the time it is created until it is deleted. in between those operations, it may be updated one or more times.

This is by design so that the index entries (which contain the rowid) will not have to be updated.

However, there are these exceptions:

0) in a partitioned table, if you change the value of the partitioning key, the row may be move dfrom one partition to another. if this happens, the rowid will change and index entries will be updated.

1) a tablemove will cause the rowid to change and the index entries to be updated.

2) If you dump and load a table, then the rowid will change because the original record will be deleted and a new one created in its stead. The table’s indexes will have to be rebuilt in this case.

-gus

This thread is closed