all 14 comments

sorted by: hot top controversial new old
[–] 5 points 4 months ago (2 children)

I swear Postgres always has new features whenever I look at it again.

I was building a system for long running durable job queues with multiple workers and of course Postgres has a solution for that. You can do row-level locking in a transaction to "reserve" jobs for the duration of that transaction, and you can use SKIP LOCKED to skip over reserved jobs so workers don't block each other. There's also LISTEN and NOTIFY if you want pub/sub to track when jobs complete, for example.

  • source
  • hideshow 2 child comments
  • [–] 1 point 4 months ago (1 child)
  • [–] 3 points 4 months ago

    The row-level locking and SKIP LOCKED seem like appropriate features for a SQL-based DBMS. I find it odd that it's not more common, actually. Even MSSQL doesn't make any promises about locking just a row and might decide to lock a whole page instead, from what I read anyway.

    NOTIFY/LISTEN might be scope creep though. I'm not really sure what led to it being implemented.

  • source
  • parent
  • [–] 11 points 4 months ago

    Seems, at a cursory look, to be a pretty solid intro to PostgreSQL. As @Valmond@lemmy.dbzer0.com commented, people sleep on SQLite. I think a lot of people skip SQLite because they think they need more. Hell, just about all my personal uses are covered with GNU recutils.

  • source
  • [–] 7 points 4 months ago (2 children)

    I hate admining PostreSQL, and groan when some app I want to use requires it. Don't get me wrong: in a corp environment where someone else is responsible for backup/restore and permissions, pgsql > *. Tooling for it is great. It has every feature. But if I have to maintain it myself, I'll chose a single file to copy and back up every time: sqlite FTW.

  • source
  • hideshow 2 child comments
  • [–] 5 points 4 months ago (6 children)

    Or SQLite for embedded systems, and a NoSQL for no-sql, and MariaDB for FOSS DB.

    Did I forget anything?

  • source
  • hideshow 6 child comments
  • [–] 4 points 4 months ago (2 children)

    And Oracle if you have way too much money just kicking around.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 5 points 4 months ago

    if tpu give rhat money to oracle you are finding an extreme facist who believes our entire life should be recorded by the government and stored on oracle servers. he honestly said it will get rid of crime since you will alwaus be watched.

  • source
  • parent
  • 9 comments in c/programming@lemmy.ml view that post
    [–] 8 points 4 months ago (1 child)

    This has pretty much been my philosophy with lemmy too.

    Additional stores, caches, and other storage layers massively increase the complexity of your system. Suddenly you have 3+ places where the user could be getting the data from, and any of them might contain stale or incorrect data, that isn't linked or connected to primary source data.

    Even after you add 2 of these layers, troubleshooting and finding problems is only solvable by people who know intimately how all of these things are connected. So I've always tried to keep these extra layers out of the lemmy codebase.

  • source
  • hideshow 1 child comment
  • [–] [S] 4 points 4 months ago

    I've come to the same realization, the less moving pieces you have in your stack the better. Postgres can handle vast majority of persistence needs, and can even double up as a queue. So, there's really little justification adding another moving piece which you'll have to synchronize data with.

  • source
  • parent
  • [–] 7 points 4 months ago (6 children)

    *Except when all you need is SQLite.

  • source
  • hideshow 6 child comments
  • [–] [S] 4 points 4 months ago (5 children)

    Yeah, it's amazing how good SQLite is nowadays. I find I use it for a lot of local apps I make for myself cause it's just good enough.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 4 months ago (4 children)

    SQLite is pretty incredible. I think it currently has even faster read performance than postgres.

    The only reason to not use it, is if you have a write-heavy DB, or you need some of postgres's extra features.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 4 months ago*

    we have more performance issues developing gotosocial with postgres than with sqlite. if we supported multinode deployments or horizontal scaling such that sqlite's concurrency got harder to reason-about I'm sure postgres would shine, but for a single process sqlite has been generally much faster and it hasn't required anywhere near as much prompting to get the query planner to behave as required.

    i also think when people assume sqlite is better for simpler applications, they think smaller. but no, for the same 25+GB databases sqlite has mopped the floor with performance.

    single-process multi-threaded sqlite is fantastic.

  • source
  • parent
  • 1 comment in c/postgresql@programming.dev view that post
    [–] 1 point 4 months ago