Coder Social home page Coder Social logo

SQL Server equivalent possible? about idgen HOT 3 CLOSED

robthree avatar robthree commented on July 19, 2024
SQL Server equivalent possible?

from idgen.

Comments (3)

RobThree avatar RobThree commented on July 19, 2024 1

There may be other ways to achieve this. AFAIK you can load .Net assemblies into SQL server. I'm not sure about the lifetime of these loaded objects (do they only exist within the scope of the function or are they loaded once, globally and kept around) or other challenges you may run into but it may be worth looking into.

On resetting the Sequence you were referring to: theoretically you wouldn't have to. It might not be the exact same behaviour as IdGen implements, but you could just let it count up and either have it overflow and 'wrap around' or reset it at another given interval entirely (with careful consideration ofcourse).

from idgen.

RobThree avatar RobThree commented on July 19, 2024

I think the biggest challenge would be to keep some sort of state between invocations for the sequence-part of the ID. You could -ofcourse- store that in a table or something but I'm not sure if that would be efficient and although I have some experience with SQL Server, I couldn't tell you of the top of my head if it would be possible to store a global 'counter variable' in memory (without concurrency issues). Other than that I don't see why it wouldn't work as a SQL server function; you could even leave all the 'variable width' of the fields and just use some fixed values which should make things a little easier.

So, the theory works, a server should be able to generate an ID without collisions as long as it has a reserved GeneratorId; I'm just not so sure about the Sequence part.

from idgen.

vyrotek avatar vyrotek commented on July 19, 2024

Indeed, that's the part I was wondering about too. One might be able to do it using/resetting SQL Server's Sequence feature but it would be quite a hack. Snowflake IDs are very powerful, but we've been reviewing the trade-offs vs. traditional Identity or GUIDs and one concern is giving up SQL generated IDs. Can't have it all, I suppose. 😅

Thanks for your thoughts!

from idgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.