Unofficial Hacker News companion — get notified on comment replies, and more.

What Changes When You Upgrade from PostgreSQL 18 to 19 (opens external site)

137 points by rgoomar 5 days ago | rishigoomar.com | 75 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (22)

  1. Timestampz discards the timezone and converts to utc, meaning it is a destructible operation — you cannot bring back the original.

    This may be important in many cases: for example antifraud where you want to store also what was literally on the user’s clock (including timezone) and show it later in reports and what have you

    Replies (4)
    1. I agree that the MSSQL timezoneoffset approach is the best.

      However the Postgres (and others) work-around is simply to add a LocalTimeZone field where necessary.

      Yeah, it's not as convenient, but it's a simple, effective, work-around.

      For me, this isn't the killer-app distinction that suggests choosing MSSQL over Postgres.

      Replies (1)
      1. > I agree that the MSSQL timezoneoffset approach is the best.

        It is not. A static offset is largely equivalent to a utc timestamp, and thus useless for any consideration of future event.

        If you’re concerned about the limited historical and auditing value, it’s not exactly difficult to just tack that information on in a second column, or create a custom type which you can even call datetimeoffset but hanging the entire thing on that edge case is nonsense.

        Hell, if you’re concerned about auditing events or fraud control you want a ton more data than just a timezone offset advertised by the client, and storing an entire timestamp just to keep that datum around is an unnecessary waste.

        Replies (2)
        1. Yes, the work-around is simple (as I said above.)

          A static offset however is not equivalent to storing as utc. Storing the local offset is objectively more information than not.

          But yes, the workaround is simple.

          Replies (1)
          1. > A static offset however is not equivalent to storing as utc. Storing the local offset is objectively more information than not.

            From a datetime manipulation perspective it makes no difference, both are instants and nothing more. Hence my very specific use of “largely equivalent” and further qualification, rather than calling them identical.

            A static offset is information in the same sense storing a traceability report for every number is information: it’s metadata, and in most cases it’s closer to hoarding than anything useful.

            Replies (1)
            1. >> From a datetime manipulation perspective it makes no difference, both are instants and nothing more

              True, but they are instants that include local time zone information.

              For example, in a town straddling a time zone boundary its useful to know what time is where.

              The MSSQL approach is better because it explicitly contains what it says; timestamp with time zone. Postgres explicitly does not store the time zone, preferring instead to store utc time.

              The work around is simple, but postgres objectively stores less information.

              Continue this thread (1 replies) →

        2. You may have a lot of dates. And thus would need a lot of “second” columns.
          Replies (1)
          1. Ok?
    2. This kind of audit trail sounds like a "store a string" nail or hammer.
    3. Even worse: your future timestamps will be corrupted if the timezone definition ever changes!

      Your country abolishes DST? Good luck trying to fix that mess...

      Replies (1)
      1. Imagine some kind of assessment system (like tests / questionnaires); the only relevant “time” is during that assessment.

        You would not need to convert that time to some other time zone and what have you 3 years from now.

        For other stuff, of course, utc is enough.

        However it is just huge amount of cope trying to defend that you cannot store what ms sql allows you to.

        Replies (1)
        1. Pg can store it, either as an extra column or a custom type. DatetimeOffset isn't in the standard, which I think speaks to how niche the need is.
          Replies (1)
          1. I understand it is not a standard, but these types are very common in programming languages. If need to jump through hoops to store your data (ORM), this is not user-friendly, that's all.
            Replies (1)
            1. > these types are very common in programming languages

              Mostly out of legacy mistakes in datetime handling.

    4. That's a problem only because your data model doesn't take into account how to make user supplied datetime work. Timestamp and the likes are not for user supplied data, datetime is. And if you are going to deal with it, you should store two dates: what the user said and what the datetime in utc is at the moment of recording. That gives you everything you will ever need: comparison between timezones, offsets regardless of timezones and a coherent user presentation.
      Replies (2)
      1. Dude, you literally have datetimeoffset in ms sql
        Replies (3)
        1. That's not SQL standard. Pg can provide similar functionality with custom types and functions, if it must be a single assignment and output.
          Replies (1)
          1. Like I’ve said with an example of prefix case-insensitive search, some things like ms sql are user-friendly and down to earth problems, and others have excuses "you are holding it wrong".
        2. Congratulations. MSSQL has some good features. Its cost, administrative overhead, and lack of available source make it an unacceptable option for a lot of people. Postgres also has lots of features that MSSQL does not have. Not sure why any of this is relevant in a post about differences in the new PG version.
        3. And? I'm questioning your data model, same problem will happen no matter your database, because now you have to consider DST and comparisons between timezones that are timezone sensitive. Meanwhile storing UTC and as user supplied it both gives you the most flexibility for any representation of date time that your application might need. Not counting that now you are shackled to a vendor like the sibling comment notes, because it's not standard sql
      2. Any solution that does not capture the timezone will be wrong sometimes. Your described solution falls on its face for any situation where an offset doesn't uniquely identify the timezone. For example, Arizona does not recognize daylight savings time, so sometimes it's got the same offset as Mountain Time, other times it has the same offset as Pacific Time.