Coder Social home page Coder Social logo

Comments (6)

mattrobenolt avatar mattrobenolt commented on May 23, 2024

Can you explain what this means? Are you suggesting a feature where rows can be written with a TTL and they auto-delete? If so, this is firmly in the realm of MySQL would need to support this and outside of the scope of our driver. But in general there are lots of established patterns for doing this in relational databases, I'm just curious what you have in mind and maybe we can guide you to a solution.

from database-js.

mattrobenolt avatar mattrobenolt commented on May 23, 2024

Oh wow, I'm assuming you mean https://dev.mysql.com/doc/refman/8.0/en/create-event.html

I wasn't even aware of this being a thing. I haven't poked around, but I suspect then that this is lack of support in Vitess that we'd need.

from database-js.

iheanyi avatar iheanyi commented on May 23, 2024

Hey there! I was reading the MySQL documentation on this and you're right, this is something that we do not support. If a record is subject to a TTL, I'd suggest handling this at the application level. A pattern for doing this is to set a timestamp based on TTL on each row and having a scheduled job that runs a set interval of time to do what you need. This is a pattern that we use internally at PlanetScale for this type of thing and it works really well for us. I hope this helps out!

If that doesn't fit your use-case, I suggest opening an issue in the Vitess repository, where this is the root of the issue. Thanks!

from database-js.

CanRau avatar CanRau commented on May 23, 2024

Extending on iheanyi you don't even have to remove those "TTL" columns on time, I do the same for sessions and the query just checks that the TTL is in the future and hasn't expired yet

from database-js.

205g0 avatar 205g0 commented on May 23, 2024

@CanRau but then the database fills up with data you won't need

@iheanyi it was clear to me how to do this manually. the point is that it's still some significant effort and you need a dedicated process vs setting some ttl (as with most other dbs) and call it a day

Also not sure if Vitess and/or PS can support this b/c this would require a long-running process

from database-js.

CanRau avatar CanRau commented on May 23, 2024

Yea I see, my comment was meant like, the cron or whatever doesn't need to run as exact/often to ensure expired rows are deleted on time, it can "just" run every hour or whatever and remove everything already expired.
But yea this requires some additional code/system.
Just saw that EVENT is basically a cron like scheduler.
Currently Vitess doesn't support stored procedures at all afaik, and this looks similar.

I accept some of those missing pieces for the benefits of the platform and personally need cron like stuff anyway, which I can then use to clean up old db stuff as well.

from database-js.

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.