ChimpScanner@programming.devtoProgramming.dev Meta@programming.dev•Call for AssistanceEnglish
2·
1 year agoI shortly looked through the source code for Lemmy, and it’s using a Rust ORM named Diesel. I don’t know Rust at all, but it seems like in order to add the ability for pgbouncer, two things would need to be done.
- There would have to be separate environment variables for a direct connection to the database, to run migrations. Prisma (an ORM for Node.js, which I am more familiar with) does something similar: https://www.prisma.io/docs/data-platform/data-proxy/prisma-cli-with-data-proxy#set-a-direct-database-connection-url-in-your-prisma-schema. From my understanding, pgbouncer is essentially a queue for the database. So if you have a bunch of things in the queue, it will delay your migrations from running.
- Once step 1 is completed, the regular database environment variables can point to the pgbouncer connection pool. Based on the pgbouncer documentation: PgBouncer acts as a Postgres server, so simply point your client to the PgBouncer port.
Like I said, I don’t know Rust but I would be interested in learning it if I have time. Or maybe someone else in the open-source community could work on this. There’s no specific issue for adding pgbouncer support, but there’s an issue about slow SQL queries that mentions it: https://github.com/LemmyNet/lemmy/issues/2877
Nice suggestions! If you want something chill, I recommend David Maxim Micic or Plini. If you want something more technical, Polyphia and Intervals are all amazing.