Is NEWSEQUENTIALID unique within a database for Many tables?











up vote
1
down vote

favorite












Is NEWSEQUENTIALID unique within a database? We plan many tables in a database with NEWSEQUENTIALID, inserting simultaneously and want to ensure every guid will be unique, regardless if they are in different tables.



Regular NEWID() will guarantee uniqueness in a database, and chances of having duplicate is chance of being struck by asteroid/lightning, however they do not alleviate the fragmentation issue.



This article talks about Mac address, however I want to specify question for database specific above.
https://stackoverflow.com/questions/28404964/is-uniqueidentifier-unique-across-databases










share|improve this question


























    up vote
    1
    down vote

    favorite












    Is NEWSEQUENTIALID unique within a database? We plan many tables in a database with NEWSEQUENTIALID, inserting simultaneously and want to ensure every guid will be unique, regardless if they are in different tables.



    Regular NEWID() will guarantee uniqueness in a database, and chances of having duplicate is chance of being struck by asteroid/lightning, however they do not alleviate the fragmentation issue.



    This article talks about Mac address, however I want to specify question for database specific above.
    https://stackoverflow.com/questions/28404964/is-uniqueidentifier-unique-across-databases










    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      Is NEWSEQUENTIALID unique within a database? We plan many tables in a database with NEWSEQUENTIALID, inserting simultaneously and want to ensure every guid will be unique, regardless if they are in different tables.



      Regular NEWID() will guarantee uniqueness in a database, and chances of having duplicate is chance of being struck by asteroid/lightning, however they do not alleviate the fragmentation issue.



      This article talks about Mac address, however I want to specify question for database specific above.
      https://stackoverflow.com/questions/28404964/is-uniqueidentifier-unique-across-databases










      share|improve this question













      Is NEWSEQUENTIALID unique within a database? We plan many tables in a database with NEWSEQUENTIALID, inserting simultaneously and want to ensure every guid will be unique, regardless if they are in different tables.



      Regular NEWID() will guarantee uniqueness in a database, and chances of having duplicate is chance of being struck by asteroid/lightning, however they do not alleviate the fragmentation issue.



      This article talks about Mac address, however I want to specify question for database specific above.
      https://stackoverflow.com/questions/28404964/is-uniqueidentifier-unique-across-databases







      sql-server database-design sql-server-2016 performance-tuning






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 4 hours ago









      knightbob472

      92113




      92113






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          According to Microsoft Docs the value is unique on a per computer basis, and also on multiple computers as long as the computer in question has a network card (assumedly the generation algorithm uses some values taken from the network card to generate the GUID)




          Each GUID generated by using NEWSEQUENTIALID is unique on that computer. GUIDs generated by using NEWSEQUENTIALID are unique across multiple computers only if the source computer has a network card.




          Other than this though, there do seem to be some caveats around that uniqueness:




          The UuidCreateSequential function has hardware dependencies. On SQL Server, clusters of sequential values can develop when databases (such as contained databases) are moved to other computers. When using Always On and on SQL Database, clusters of sequential values can develop if the database fails over to a different computer.




          And on the page for UuidCreateSequential we can also see that the function is guaranteed to be unique across computers if the network card is present




          Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.







          share|improve this answer





















          • ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
            – knightbob472
            3 hours ago










          • @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
            – George.Palacios
            3 hours ago












          • @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
            – Zane
            3 hours ago










          • Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
            – knightbob472
            2 hours ago




















          up vote
          2
          down vote













          Acording to the documentation from Microsoft.



          NEWSEQUENTIALID




          Creates a GUID that is greater than any GUID previously generated by
          this function on a specified computer since Windows was started. After
          restarting Windows, the GUID can start again from a lower range, but
          is still globally unique




          I recommend using NEWSEQUENTIALID over NEWID() for any case that that you aren't relying on the built in randomness, mainly due to the fragmentation issues associated with random GUIDs. There is a fantastic article by Kimberly Tripp on some of the pitfalls of using NEWID() on a Primary key.



          There are a few situations where NEWSEQUENTIALID may not guarantee uniqueness as are listed in the documentation.




          The UuidCreateSequential function has hardware dependencies. On SQL
          Server, clusters of sequential values can develop when databases (such
          as contained databases) are moved to other computers. When using
          Always On and on SQL Database, clusters of sequential values can
          develop if the database fails over to a different computer.




          However judging by the phrasing of your question it seems like this will be contained on a single database server.



          It is also worth noting(not that it applies here) that NEWSEQUENTIALID can be predicted so if privacy of that GUID is a concern this could also be a problem.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f224783%2fis-newsequentialid-unique-within-a-database-for-many-tables%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            According to Microsoft Docs the value is unique on a per computer basis, and also on multiple computers as long as the computer in question has a network card (assumedly the generation algorithm uses some values taken from the network card to generate the GUID)




            Each GUID generated by using NEWSEQUENTIALID is unique on that computer. GUIDs generated by using NEWSEQUENTIALID are unique across multiple computers only if the source computer has a network card.




            Other than this though, there do seem to be some caveats around that uniqueness:




            The UuidCreateSequential function has hardware dependencies. On SQL Server, clusters of sequential values can develop when databases (such as contained databases) are moved to other computers. When using Always On and on SQL Database, clusters of sequential values can develop if the database fails over to a different computer.




            And on the page for UuidCreateSequential we can also see that the function is guaranteed to be unique across computers if the network card is present




            Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.







            share|improve this answer





















            • ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
              – knightbob472
              3 hours ago










            • @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
              – George.Palacios
              3 hours ago












            • @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
              – Zane
              3 hours ago










            • Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
              – knightbob472
              2 hours ago

















            up vote
            2
            down vote













            According to Microsoft Docs the value is unique on a per computer basis, and also on multiple computers as long as the computer in question has a network card (assumedly the generation algorithm uses some values taken from the network card to generate the GUID)




            Each GUID generated by using NEWSEQUENTIALID is unique on that computer. GUIDs generated by using NEWSEQUENTIALID are unique across multiple computers only if the source computer has a network card.




            Other than this though, there do seem to be some caveats around that uniqueness:




            The UuidCreateSequential function has hardware dependencies. On SQL Server, clusters of sequential values can develop when databases (such as contained databases) are moved to other computers. When using Always On and on SQL Database, clusters of sequential values can develop if the database fails over to a different computer.




            And on the page for UuidCreateSequential we can also see that the function is guaranteed to be unique across computers if the network card is present




            Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.







            share|improve this answer





















            • ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
              – knightbob472
              3 hours ago










            • @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
              – George.Palacios
              3 hours ago












            • @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
              – Zane
              3 hours ago










            • Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
              – knightbob472
              2 hours ago















            up vote
            2
            down vote










            up vote
            2
            down vote









            According to Microsoft Docs the value is unique on a per computer basis, and also on multiple computers as long as the computer in question has a network card (assumedly the generation algorithm uses some values taken from the network card to generate the GUID)




            Each GUID generated by using NEWSEQUENTIALID is unique on that computer. GUIDs generated by using NEWSEQUENTIALID are unique across multiple computers only if the source computer has a network card.




            Other than this though, there do seem to be some caveats around that uniqueness:




            The UuidCreateSequential function has hardware dependencies. On SQL Server, clusters of sequential values can develop when databases (such as contained databases) are moved to other computers. When using Always On and on SQL Database, clusters of sequential values can develop if the database fails over to a different computer.




            And on the page for UuidCreateSequential we can also see that the function is guaranteed to be unique across computers if the network card is present




            Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.







            share|improve this answer












            According to Microsoft Docs the value is unique on a per computer basis, and also on multiple computers as long as the computer in question has a network card (assumedly the generation algorithm uses some values taken from the network card to generate the GUID)




            Each GUID generated by using NEWSEQUENTIALID is unique on that computer. GUIDs generated by using NEWSEQUENTIALID are unique across multiple computers only if the source computer has a network card.




            Other than this though, there do seem to be some caveats around that uniqueness:




            The UuidCreateSequential function has hardware dependencies. On SQL Server, clusters of sequential values can develop when databases (such as contained databases) are moved to other computers. When using Always On and on SQL Database, clusters of sequential values can develop if the database fails over to a different computer.




            And on the page for UuidCreateSequential we can also see that the function is guaranteed to be unique across computers if the network card is present




            Computers with ethernet/token ring addresses generate UUIDs that are guaranteed to be globally unique.








            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 4 hours ago









            George.Palacios

            1,873721




            1,873721












            • ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
              – knightbob472
              3 hours ago










            • @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
              – George.Palacios
              3 hours ago












            • @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
              – Zane
              3 hours ago










            • Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
              – knightbob472
              2 hours ago




















            • ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
              – knightbob472
              3 hours ago










            • @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
              – George.Palacios
              3 hours ago












            • @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
              – Zane
              3 hours ago










            • Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
              – knightbob472
              2 hours ago


















            ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
            – knightbob472
            3 hours ago




            ok, we are not using APIs yet (so UuidCreateSequential will not apply to us), this is for Kimball data warehouse, so I will use NewSequentialId for all tables within database, thanks again, wonder how it will work when we move the Datawarehouse to the cloud, I will stick with Newsequential id for on premise database, Thanks
            – knightbob472
            3 hours ago












            @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
            – George.Palacios
            3 hours ago






            @knightbob472 if you look at the first link, you'll see that NewSequentialID is a wrapper for UuidCreateSequential, so you do need to read and understand both.
            – George.Palacios
            3 hours ago














            @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
            – Zane
            3 hours ago




            @knightbob472 if this answer resolves your question it's always helpful to mark it as the answer. It gives credit to the answer and informs other readers that this is a good place to look.
            – Zane
            3 hours ago












            Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
            – knightbob472
            2 hours ago






            Thanks, I usually let it sit for couple days unanswered, so it gains attention, and person can rack up more points for providing answer, it'll be accepted in few days
            – knightbob472
            2 hours ago














            up vote
            2
            down vote













            Acording to the documentation from Microsoft.



            NEWSEQUENTIALID




            Creates a GUID that is greater than any GUID previously generated by
            this function on a specified computer since Windows was started. After
            restarting Windows, the GUID can start again from a lower range, but
            is still globally unique




            I recommend using NEWSEQUENTIALID over NEWID() for any case that that you aren't relying on the built in randomness, mainly due to the fragmentation issues associated with random GUIDs. There is a fantastic article by Kimberly Tripp on some of the pitfalls of using NEWID() on a Primary key.



            There are a few situations where NEWSEQUENTIALID may not guarantee uniqueness as are listed in the documentation.




            The UuidCreateSequential function has hardware dependencies. On SQL
            Server, clusters of sequential values can develop when databases (such
            as contained databases) are moved to other computers. When using
            Always On and on SQL Database, clusters of sequential values can
            develop if the database fails over to a different computer.




            However judging by the phrasing of your question it seems like this will be contained on a single database server.



            It is also worth noting(not that it applies here) that NEWSEQUENTIALID can be predicted so if privacy of that GUID is a concern this could also be a problem.






            share|improve this answer



























              up vote
              2
              down vote













              Acording to the documentation from Microsoft.



              NEWSEQUENTIALID




              Creates a GUID that is greater than any GUID previously generated by
              this function on a specified computer since Windows was started. After
              restarting Windows, the GUID can start again from a lower range, but
              is still globally unique




              I recommend using NEWSEQUENTIALID over NEWID() for any case that that you aren't relying on the built in randomness, mainly due to the fragmentation issues associated with random GUIDs. There is a fantastic article by Kimberly Tripp on some of the pitfalls of using NEWID() on a Primary key.



              There are a few situations where NEWSEQUENTIALID may not guarantee uniqueness as are listed in the documentation.




              The UuidCreateSequential function has hardware dependencies. On SQL
              Server, clusters of sequential values can develop when databases (such
              as contained databases) are moved to other computers. When using
              Always On and on SQL Database, clusters of sequential values can
              develop if the database fails over to a different computer.




              However judging by the phrasing of your question it seems like this will be contained on a single database server.



              It is also worth noting(not that it applies here) that NEWSEQUENTIALID can be predicted so if privacy of that GUID is a concern this could also be a problem.






              share|improve this answer

























                up vote
                2
                down vote










                up vote
                2
                down vote









                Acording to the documentation from Microsoft.



                NEWSEQUENTIALID




                Creates a GUID that is greater than any GUID previously generated by
                this function on a specified computer since Windows was started. After
                restarting Windows, the GUID can start again from a lower range, but
                is still globally unique




                I recommend using NEWSEQUENTIALID over NEWID() for any case that that you aren't relying on the built in randomness, mainly due to the fragmentation issues associated with random GUIDs. There is a fantastic article by Kimberly Tripp on some of the pitfalls of using NEWID() on a Primary key.



                There are a few situations where NEWSEQUENTIALID may not guarantee uniqueness as are listed in the documentation.




                The UuidCreateSequential function has hardware dependencies. On SQL
                Server, clusters of sequential values can develop when databases (such
                as contained databases) are moved to other computers. When using
                Always On and on SQL Database, clusters of sequential values can
                develop if the database fails over to a different computer.




                However judging by the phrasing of your question it seems like this will be contained on a single database server.



                It is also worth noting(not that it applies here) that NEWSEQUENTIALID can be predicted so if privacy of that GUID is a concern this could also be a problem.






                share|improve this answer














                Acording to the documentation from Microsoft.



                NEWSEQUENTIALID




                Creates a GUID that is greater than any GUID previously generated by
                this function on a specified computer since Windows was started. After
                restarting Windows, the GUID can start again from a lower range, but
                is still globally unique




                I recommend using NEWSEQUENTIALID over NEWID() for any case that that you aren't relying on the built in randomness, mainly due to the fragmentation issues associated with random GUIDs. There is a fantastic article by Kimberly Tripp on some of the pitfalls of using NEWID() on a Primary key.



                There are a few situations where NEWSEQUENTIALID may not guarantee uniqueness as are listed in the documentation.




                The UuidCreateSequential function has hardware dependencies. On SQL
                Server, clusters of sequential values can develop when databases (such
                as contained databases) are moved to other computers. When using
                Always On and on SQL Database, clusters of sequential values can
                develop if the database fails over to a different computer.




                However judging by the phrasing of your question it seems like this will be contained on a single database server.



                It is also worth noting(not that it applies here) that NEWSEQUENTIALID can be predicted so if privacy of that GUID is a concern this could also be a problem.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 2 hours ago









                Tom V

                13.8k74676




                13.8k74676










                answered 4 hours ago









                Zane

                2,49821739




                2,49821739






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f224783%2fis-newsequentialid-unique-within-a-database-for-many-tables%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Trompette piccolo

                    Slow SSRS Report in dynamic grouping and multiple parameters

                    Simon Yates (cyclisme)