Forum Discussion

gahenry's avatar
gahenry
Copper Contributor
Jun 20, 2023

How to use ROWGUIDs

I own a small retail organization and our POS system has a SQL based backend.  As you might guess the company that does our POS system is not very helpful when we need custom work so I have been given read access to the databases and over the years  I have done some work with Access to build some systems that do reports and query tables that are not available out of the box. 

 

In order to do this, I have had to reverse engineer the table relationships (because the company will not share their schema) but as the number of our SKU’s increase  it is getting harder and harder (now over 27,000 inventory items)

 

One thing I have noticed is all of the tables have a rowguid field.  Knowing very little about SQL, I have done some research on what ROW GUID’s are  so I think I understand that they are a database wide unique identifier so you cannot have any duplicates  across tables – if that is true it Makes sense...  If not true can someone explain to me what they are

 

My questions are

 

  • how do you use ROWGUID’s in Practice , since each table in database by definition has unique value in the ROWGUID field.  Since they are unique how do you know a record in table “a” relates to another record in table “b” ?  Today, many of the tables I use for example,  have a field called  “SKU” that is common field so doing a join on SKU is easy

  • I am assuming that if I use the ROW GUID field in my query it would be faster.  Is that true?

  • Since it is up to me to reverse engineer the relationships, Does anyone have any suggestions what to look for to try to figure this out

  • Is there any documentation on the practical use of ROW GUIDs that would help me understand and improve my queries  remembering that I only have read access to the tables. and I used Access to do most of my work not to mention I am a novice at this.

Sorry for such a Novice question. Just trying to find a way to make my Access queries faster

 

Thanks


Gary

3 Replies

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    how do you use ROWGUID’s in Practice

    Hello Gary,

    A ROWGUID is used in Merge replication = distrubuted databases over several localition/regions.

    I don't know any other usefull use-case for it.

     

    I am assuming that if I use the ROW GUID field in my query it would be faster. Is that true?

    No, really not. It's a uniqueidentifier (Transact-SQL) - SQL Server | Microsoft Learn and needs 16 bytes for storage. As simple integer with IDENTITY (Function) (Transact-SQL) - SQL Server | Microsoft Learn needs only 4 bytes (for raw data + for index data); that's a 1/4. No, GUID will make it slower.

     

     

    • gahenry's avatar
      gahenry
      Copper Contributor

      Thank you for your response!!..  I knew from my readings that was what it was, but I did not know if there was a system parameter or something to access the records the RowGUID relates to.   

       

      I have a database that I have been given RO access to and no schema so I am trying to reverse engineer the relationships so I can build reports and do queries

       

      thanks again!

       

      olafhelper 

      • olafhelper's avatar
        olafhelper
        Bronze Contributor
        Better use simple integer values for primary key, with a range of 4 billion possible numbers you have a wide range and small footprint; much better then a GUID.

Resources