Hey, Threadiverse! I’m looking for informed opinions on database choices.

I can stand up an Internet-facing application and have it use either MySQL or PostgreSQL. Which is the better choice, and why do you think so?

Thanks!

  • femtech@midwest.social
    link
    fedilink
    English
    arrow-up
    12
    ·
    edit-2
    2 days ago

    Postgres, the extensions and open source community have been very helpful.

    Postgis for images

    CloudNative-pg for running DB clusters in kuberneties.

  • sugar_in_your_tea@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    12
    ·
    edit-2
    2 days ago

    Postgres. It’s more strict by default, which leads to a lot fewer surprises.

    Here’s my rule of thumb:

    1. SQLite - if it’s enough
    2. Postgres
    3. MariaDB - if you don’t care about your data and just want the thing to work
    4. MySQL - if you sold your soul to Oracle, but still can’t afford their license fee
    5. Something else - you’re a hipster or have very unique requirements
  • ShittyBeatlesFCPres@lemmy.world
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    4
    ·
    2 days ago

    The only reason I wouldn’t go with Postgres is if I planned to do other things on the same machine. MariaDB/MySQL has been around forever. You may find something that requires it — Wordpress1, for example, requires MariaDB (or MySQL but use MariaDB) and doesn’t support Postgres.

    Also, there’s solutions like Docker containers if you are running multiple things on the same server. But if you’re just learning and putting one thing on a Raspberry Pi as a project or whatever, you don’t need to learn Docker yet.

    1 I’m not recommending Wordpress. It’s ancient and has security issues all the time. But over 40% of sites on the Net still use it in some form. (I mean Wordpress.org, the open source project. The Wordpress company seems to be having some “crazy CEO” drama at the moment.)

  • halloween_spookster@lemmy.world
    link
    fedilink
    English
    arrow-up
    6
    arrow-down
    1
    ·
    2 days ago

    We have both MySQL and PostgreSQL in our production environment. Postgres is way nicer as a user of the DB. I created a document months ago outlining a dozen different things that Postgres does that MySQL either doesn’t do or does worse. I can’t speak to managing the DB as I don’t have experience with that.

  • zoostation@lemmy.world
    link
    fedilink
    English
    arrow-up
    54
    ·
    2 days ago

    Postgres is a more robust and better designed and developed product, also it’s not owned by fucking Oracle.

  • z3rOR0ne@lemmy.ml
    link
    fedilink
    English
    arrow-up
    17
    arrow-down
    1
    ·
    2 days ago

    Most applications can do just fine with SQLite, but if you need something with a lot more write speed, go with PostgreSQL.

    • pageflight@lemmy.world
      link
      fedilink
      English
      arrow-up
      26
      ·
      2 days ago

      Yeah, every time I find some weird annoying behavior or some missing feature in MySQL, PostgreSQL is doing it right.

      That said, also ask yourself if you really need a relational database, or whether an object store or append-only / timeseries db would fit better.

  • Dark Arc@social.packetloss.gg
    link
    fedilink
    English
    arrow-up
    26
    ·
    2 days ago

    PostgreSQL is just better. It’s supports transactions on DDL (things like altering table structure) and enforces unique constraints after transactions complete … so you can actually do a bunch of important stuff (like update your table structure or swap unique values between rows) safely.

    • DeadMartyr@lemmy.zip
      link
      fedilink
      English
      arrow-up
      8
      ·
      2 days ago

      I used MariaDB for school projects, what exactly is wrong with it? Asking because I’m just unaware

      • earmuff@lemmy.dbzer0.com
        link
        fedilink
        English
        arrow-up
        3
        arrow-down
        13
        ·
        edit-2
        2 days ago

        While there was a time, where those databases were considered “good”, they are only this famous because they have been free or open source for ages. Professors love open source stuff. This does not necessarily mean it is a good product in terms of database functionality. They have been stuck in the old age and simply get outperformed by almost anything. Professors also hate to change their slides and to learn something new. Because their priority is on functionality, not on real world use. And when you want to use a product in the real world, non-functional properties gain a lot of value. One of them is performance.

        If you want to have a fast, reliable, open source database, use ClickHouse.

          • earmuff@lemmy.dbzer0.com
            link
            fedilink
            English
            arrow-up
            3
            arrow-down
            2
            ·
            2 days ago

            Smear campaign with an open source product? Are you sure you still have a working organ between your ears?

            That being said, my recommendation is based on using databases in big data environments for 15 years. But I am glad that your home lab is working fine with MariaDB. Does not mean it is a good product. And your comment just proves my point.

          • dallen@programming.dev
            link
            fedilink
            English
            arrow-up
            5
            ·
            2 days ago

            The question was for an internet facing application, not a homelab.

            As someone who has dealt with MariaDB in production, I would certainly look elsewhere. Haven’t had any colleagues who would disagree…

        • sugar_in_your_tea@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          3
          arrow-down
          1
          ·
          edit-2
          2 days ago

          Generally speaking, if a professor recommends something, it probably sucks. Their information is incredibly outdated and is usually whatever they used in their own undergrad program.

          At school I learned:

          • Java
          • PHP
          • MySQL
          • C#
          • C++
          • Racket (Lisp)

          Each of those has a better alternative, with C# being the least bad. For example:

          • Java -> Kotlin
          • PHP -> Python
          • MySQL -> SQLite or Postgres
          • C# -> Python (desktop QT GUIs) or web stack (e.g. Tauri for desktop web stack)
          • C++ -> Rust (non-games) or a game engine
          • Lisp -> Haskell

          Formal education is for learning concepts, learn programming languages and tools on your own.

  • droopy4096@lemmy.ca
    link
    fedilink
    English
    arrow-up
    4
    arrow-down
    1
    ·
    2 days ago

    My opinion is that of the two Postres is more “adult”. So if you want to"just wing it" MariaDB would work, but if you’re serious Postgres is a better choice. However Postgres also requires better understanding of you setup etc. So it’s a ROI game - what’s more important to your project, how complex your DB is, what are the requirements for availability, transaction security etc. There is no “better” or “worse” there’s “feasible” and “prohibitive” 😉

  • threesigma@lemm.ee
    link
    fedilink
    English
    arrow-up
    18
    ·
    2 days ago

    Postgres also had the advantage of great support for JSON elements, which gives you the power of a no-sql system like mongo in the package. A major selling point if your schema is evolving.

  • Jeena@piefed.jeena.net
    link
    fedilink
    English
    arrow-up
    12
    arrow-down
    1
    ·
    2 days ago

    PostgreSQL is the more feature rich, but if you don’t care about all those features like saving and searching in json structures, Geo data structures and a to of other stuff because you have a simple APO then MySQL is good enough, maybe even SQLite.

    • expr@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 days ago

      Its query planner is also much, much more powerful. Like it’s not even close.

      There’s hardly any good reason to use MySQL today. Postgres is easier and nicer to work with, with a strong community backing it.

      SQLite is completely different from both and has entirely different usecases.

  • barkingspiders@infosec.pub
    link
    fedilink
    English
    arrow-up
    14
    ·
    2 days ago

    Choosing is not so much about whether it’s internet facing or not. From the programmer’s perspective and an administrator’s perspective there are pros and cons to both. As someone looking to self-host, if you want to run a service that works with either, I would make the choice based on what seems the most supported, or which one you feel the most comfortable looking up and performing administrative tasks on. I tend to use postgresql more just because I have more experience with it and can recommend it if that’s what you need, but mysql can be just as good or better in many circumstances. Pick whichever one looks easier to you.