Your database will break in 2038 (or sooner)

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 108

  • @arcanernz
    @arcanernz Рік тому +87

    The automatic timezone conversion is the reason we DON'T use timestamp. It's also much easier to have everything be in UTC and convert as necessary (and explicitly), preferably on the client or client interfacing endpoints. Now we just have to worry about the year 10,000.

    • @PlanetScale
      @PlanetScale  Рік тому +21

      May we live to see the year 10,000

    • @ZephrymWOW
      @ZephrymWOW Рік тому +9

      @@PlanetScale If we are still using MySQL in the year 10,000 I hope we don't live to see that year

    • @NerdyWasTaken
      @NerdyWasTaken Рік тому

      you guys still use MySQL?

    • @PlanetScale
      @PlanetScale  Рік тому +6

      @@NerdyWasTaken always have, always will

    • @arcanernz
      @arcanernz Рік тому

      @@NerdyWasTaken I would like to use Postgres but not my decision.

  • @flipperiflop
    @flipperiflop Рік тому +28

    I feel bad for developers that have to support timezones in different planets and galaxies

    • @PlanetScale
      @PlanetScale  Рік тому +7

      I better be retired by then

    • @gosnooky
      @gosnooky Рік тому +1

      By that time, AI will do all that for us.

    • @manu144x
      @manu144x 9 місяців тому

      I tremble a little every time I hear SpaceX made some progress with their big starships.
      I just know we'll soon need to implement mars vs earth timezones, not to mention taking into account the communications delay based on the relative distance between earth and mars which is also based on the yearly orbits around the sun of both planets.
      I hope to be rich and retired by then :))

  • @brentspotswood
    @brentspotswood Рік тому +8

    On a related note, there's also a 2040 problem with a bunch of old COBOL (and other language) programs on IBM systems. It's basically the Y2K problem again, but shifted by 40 years. This is a problem on IBM systems where they supported a 2-digit year in dates, but the 100 year period isn't 1900-1999. It's 1940-2039. There's a bunch of stuff out there that thinks that if the 2 digits are 40-99 then it's 1900+year, otherwise 20+year. There's even a lot of business logic that relies on 12/31/2039 being logically a "forever date", or a "no end date" in a from/thru date range. Maybe these systems will not survive another 15 years, but if they do then it might get interesting. Lots of major businesses still use these systems and this old code.

    • @himanshutripathi7441
      @himanshutripathi7441 11 місяців тому +1

      i see y2k problems i see employment ; desperate me

    • @saitamaicrag
      @saitamaicrag 2 дні тому

      @@himanshutripathi7441 one person's failure is another's job security.

  • @derhintze
    @derhintze 11 місяців тому +2

    Working in the aerospace industry, I'm doing software engineering and need to account for long term storage of spacecraft.. so we need to support software well into the thirties, depending on the mission. So the 2038 issue is a real thing for us today.

  • @fbodirector7464
    @fbodirector7464 Рік тому +19

    I always store values as DateTime values, so I don't have to worry about the epochalypse anyway.

    • @PlanetScale
      @PlanetScale  Рік тому +3

      🧠

    • @DoubleM55
      @DoubleM55 Рік тому +2

      Even better store it as varchar, so not even y10k will be your problem :D

    • @owenwexler7214
      @owenwexler7214 Рік тому +1

      Same, all dates in my web app's database are stored as ISO strings. Big brain stuff.

  • @n0b0dy241
    @n0b0dy241 Рік тому +4

    Rather than using datetime why can't MySQL just add a timestamp64 type and we change our timestamp columns to that?

    • @PlanetScale
      @PlanetScale  Рік тому

      Not sure! It's possible they'll do something before doomsday, but for now just don't store future values in timestamps.

  • @aqua1144
    @aqua1144 Рік тому +2

    keep up the quality content. subscribed!

  • @onosekewenu
    @onosekewenu 11 місяців тому

    Thanks for this. I honestly didn't know about MySQL's 2038 problem until now.

  • @ghostfrost3883
    @ghostfrost3883 4 місяці тому

    very knowledgeable & I always get to know something I didn't know earlier, great content 💜

  • @drT-g6p
    @drT-g6p Рік тому +4

    "you need to retire" .... best advice ever :D

  • @KWerder92
    @KWerder92 Рік тому +1

    Nice I just checked our DB and we have a timestamp column for reminder dates. Guess will change that to datetime soon. Thanks!

  • @nelson6e65
    @nelson6e65 Рік тому +1

    The problem of using DATETIME is that you don't know from “where” (what timezone) it was stored, so it's difficult to detect the timezone (for created_at, updated_at, etc. that don't need country context, like birthdate, for example).
    It's the responsibility of backends to handle this and store it in a unified timezone (for example, UTC) *manually* .
    But for access from database directly (on another application/backend) you don't actually know in what timezone was stored that date.
    (For example, for an PHP application, you add another Node.js application and other team using Python, in different servers)
    For TIMESTAMP you *know* for sure it's in UTC. I think it is easy for interoperability.

  • @nomadshiba
    @nomadshiba Рік тому +5

    not yours but in some other videos i see people mention y2k and say "it wasnt that much of a big deal after all" or similar stuff, totally unaware of the people who worked day and night to make sure everything just kept working.

    • @PlanetScale
      @PlanetScale  Рік тому +1

      Very true! My dad was a DBA in the 90s and early 2000s, I bet he has some good stories there

  • @mohannadize
    @mohannadize Рік тому +1

    Thank you! You really choose a topic that was causing me so much headache and I haven't thought of searching for a solution for it 😂, I got used to always dodge (and got really good at it) it by fixing my timestamp timezones manually at the back-end. Very insightful!

  • @iojourny
    @iojourny Рік тому +2

    Heh, I always put my timestamps into varchar(14/20) columns, depending on whether I'm expecting mili/nano second accuracy to be required.
    Either way, it always seemed crazy to me storing it in something that fits so tightly in terms of space.

    • @PlanetScale
      @PlanetScale  Рік тому

      varchar! That's wild! I'd say int, if anything.

    • @iojourny
      @iojourny Рік тому

      @@PlanetScale The application is the one who is responsible for all timing and sync, so it's usually de-facto an int, but it gets converted.
      The reason its varchar is because I need to be ready to support both INT and FLOAT, to varying degrees of accuracy, and I need the accuracy to be explicitly stated in the data (via a dot).

  • @alvaroaquije2572
    @alvaroaquije2572 Рік тому

    jeez i needed this vid, amazing as always Aaron

  • @asdfasdfuhf
    @asdfasdfuhf 9 місяців тому

    What timezone does planetscale use? The timezone of the region the database is hosted in, or the timezone of where the request comes from?

  • @byronwheeler
    @byronwheeler Рік тому +1

    Thanks for the video. Could you do one on using triggers? Thanks

  • @iwolfman37
    @iwolfman37 11 місяців тому

    all i got from this is that timestamps, which i didn't even know was an alternative to datetime, are inferior in every way. thanks! :D

    • @PlanetScale
      @PlanetScale  11 місяців тому +1

      Haha I'll take it! You're welcome

  • @nomadshiba
    @nomadshiba Рік тому +1

    working with dates as months days and years etc is a nightmare.
    i prefer using UTC time with 64bit integer. easier to use and more predictable.
    and can go to negative which lets you represent any date from BC to AC

    • @dealloc
      @dealloc Рік тому

      Unfortunately you don't get the benefits of built-in functions, also difficult to explicitly define that the integer represents a specific date range, whether it being a 64-bit epoch timestamp in seconds, milliseconds, microseconds or any other unit.
      Additionally, this is left up to application code to handle it, so as long as the DB and application code is tight, it's not a problem. But having multiple services can make this a headache in the future without proper specification.

    • @nomadshiba
      @nomadshiba Рік тому

      ​@@dealloc True, if you don't have something in between, or proper specification.
      But, still better and worth it, if the code knows what its dealing with and that's how you deal with dates everywhere in every codebase.
      Even with DateTime, there is something weird about using a human readable date in the code or query that doesn't mean anything to you until you make it human readable again for the timezone you want.

  • @owenwexler7214
    @owenwexler7214 Рік тому +1

    All the fake dates in my web app's development database are from 2034-2036, we barely missed a Y2038 problem of our own making apparently. (We use future dates because filtering out things that occurred in the past is part of our functionality and using dates way in the future in dev data is the most solid way to make sure this functionality works in development)

  • @josecanciani
    @josecanciani 11 місяців тому

    Are there any plans to, I don't know, just add an extra byte to store more numbers in the timestamp column? Is Mysql official standpoint to migrate to an 8byte datetime column?

  • @lamka02sk
    @lamka02sk Рік тому

    Another problem with timestamp column is daylight savings. Eveything just moves by 1 hour twice a year. Fun

  • @michaeldabate6358
    @michaeldabate6358 Рік тому +1

    Great explanation. The use case of a library inventory with a "Due Date" column was my first thought for storing future dates. Would it be "better" to instead store "Checkout Date" and "Days Allowed", with overdue status being determined during a query? (Different users having different checkout period allowances)

    • @PlanetScale
      @PlanetScale  Рік тому +1

      I'd say anything that stores future values should probably be a datetime, to be safest!

  • @Kane0123
    @Kane0123 Рік тому +1

    The “retire” comment has resulted in me subscribing to the channel. Classic.

  • @CRBarchager
    @CRBarchager Рік тому

    If the only difference between TimeStamp and DateTime is the value being able to store and the auto UTC conversion. Wouldn't it just be easier from future databaes just to not use TimeStamp type? -

    • @PlanetScale
      @PlanetScale  Рік тому

      That's certainly an option! Datetimes are also twice as big as timestamps, so it's not totally "free"

  • @dynamohack
    @dynamohack Рік тому

    i was thinking whole time using date time that i was wrong people use time stamp so i must use it but now i was right the every time when i set datetime
    e

  • @nometutentegiapreso
    @nometutentegiapreso Рік тому +2

    Can I get both a fun and a lame response?
    Nice video btw, I really like your channel 😊

    • @PlanetScale
      @PlanetScale  Рік тому +4

      Thanks! I appreciate that! Make sure you tell your friends, so I can retire as soon as possible

    • @PlanetScale
      @PlanetScale  Рік тому +5

      PlanetScale, the corporation, appreciates your support. Please make sure to follow us on LinkedIn
      (lame)

    • @nometutentegiapreso
      @nometutentegiapreso Рік тому

      I got exactly what I asked for, no complaints here 😂

    • @keent
      @keent Рік тому

      this channel is awesome lmaooo

  • @neociber24
    @neociber24 Рік тому +1

    So in 2038 people will finally update their MySQL?

  • @gosnooky
    @gosnooky Рік тому

    I like how he looked at a watch that didn't exist. I do the same thing. I'd wager that in the next 15 years, there will be a solution using some new tech we can't yet conceive.

    • @PlanetScale
      @PlanetScale  Рік тому

      Haha I do that all the time 😂 It's kind of habit at this point

  • @FlygOnLiTe
    @FlygOnLiTe Рік тому

    Is it a bad idea to use a ISO 8601 as a varchar type instead of using a real datetime? I'm confused about how I'm supposed to set the time to UTC in my application framework. Do you mean like converting the date timezones with something like dayjs before inserting it into the db?

    • @PlanetScale
      @PlanetScale  Рік тому +3

      I would personally always store data in their most "honest" types. So if it's a date I'd store it as a date.
      Your application framework (Laravel, Rails, etc) should be able to set a connection timezone when connecting to the DB. That will ensure that you're always operating in UTC and not in some other random server timezone

  • @lpanebr
    @lpanebr Рік тому

    LOL incontrollably at solving the problem by retiring!

  • @levibaraka
    @levibaraka Рік тому +1

    This is me feeling like a super hero after liking and subscribing to help you get out of the game sooner 😂

  • @loclghst
    @loclghst Рік тому +1

    Love it.

  • @KellenProctor
    @KellenProctor Рік тому

    What's the Mac App you're using?

  • @Pawlo370
    @Pawlo370 Рік тому

    Pov Polish doctors of the National Health Fund (NFZ) setting your appointment for 20 years because there are no earlier dates XD

  • @npc73x
    @npc73x Рік тому

    What about the Y1000 problem

  • @lapulapucityrider3227
    @lapulapucityrider3227 Рік тому

    does posgres also has this problem?

    • @PlanetScale
      @PlanetScale  Рік тому

      Not sure, you'd have to check the legal range of their timestamp column

  • @jurgentreep
    @jurgentreep Рік тому

    I like your humor 😂

  • @mazingguitar
    @mazingguitar Рік тому

    You've calmed with this one. Imagine all those migrations to be done. Ahh the life of software engineer :D

  • @liaosankai
    @liaosankai Рік тому

    🙂How about topic for regarding the use of int, uuid, or ulid in table primary key design?

    • @PlanetScale
      @PlanetScale  Рік тому +1

      On my list! Good idea

    • @owenwexler7214
      @owenwexler7214 Рік тому +1

      In short: INTs and SERIALs are insecure (see Parler hack), UUIDs are slow, and ULIDs are faster than UUIDs and slower but more secure than INTs but are more obscure, have less compatibility, and do not have built-in generator functions or even type definitions in many databases (I think they do in MySQL if I'm not mistaken).

  • @Sergey-jq5kz
    @Sergey-jq5kz Рік тому

    why not change int to int unsigned?

    • @PlanetScale
      @PlanetScale  Рік тому

      Totally possible. You'd have to do a bit of type juggling with your queries, but that definitely works

  • @gofullstack
    @gofullstack 10 місяців тому

    4:15 🤣🤣🤣

  • @Dev-Siri
    @Dev-Siri Рік тому

    forget the actual problem. we need an actual cool-sounding acronym for this issue.
    Epochalypse is way too simple, Y2038 is not scary enough, Y2k38's length is an odd int.

    • @PlanetScale
      @PlanetScale  Рік тому

      What are you on about! Epochalypse is the coolest possible name! I dare you to come up with something funnier than epochalypse (impossible)

    • @Dev-Siri
      @Dev-Siri Рік тому

      ​@@PlanetScale I just think epochalypse is way to simple, and simplicity is forbidden in the software world. but I'm bad at cool acronyms, so, uhhhh, you win

    • @PlanetScale
      @PlanetScale  Рік тому

      @@Dev-Siri win by default, I'll still take it.

  • @chrishabgood8900
    @chrishabgood8900 11 місяців тому

    2038 but not 2037? Weird

  • @EddyVinck
    @EddyVinck 10 місяців тому

    !remindme 15 years

  • @Im_Ninooo
    @Im_Ninooo Рік тому

    *laughs in CockroachDB which goes until year 294276*

    • @PlanetScale
      @PlanetScale  Рік тому +1

      I'll definitely be retired by then

  • @jessieonfly
    @jessieonfly Рік тому

    It just need to be updated

  • @geHuC
    @geHuC Рік тому

    I keep my dates as integers so should be good for abotu 18 days more till the 19th of jan 2038 :D

  • @SquaredbyX
    @SquaredbyX Рік тому

    ORLY... the varchar language is guilty of range discrimination? Who couldn't have seen that coming?

  • @razt3757
    @razt3757 Рік тому

    What if we convert the timestamp cols into int cols? Shouldn't that remove the 4 byte constraint and the automatic UTC conversion?

    • @PlanetScale
      @PlanetScale  Рік тому +2

      Yup, storing as ints would work! It would require a bit of juggling in your queries, as they are no longer retain their semantic meaning as date+time, but that can be solved at the app layer.

  • @CaedenClark
    @CaedenClark 7 місяців тому

    your 34 you look mid 20s

  • @Guilherme-qk9so
    @Guilherme-qk9so 10 місяців тому

    unsubbing so you can't retire and we can have your videos for longer