Earlier quoted context omitted.
At low-medium scale, this will be fine. Even at higher scale, so long as you monitor autovacuum performance on the queue table. At some point it may become practical to bring a dedicated queue system into the stack, sure, but this can massively simplify things when you don’t need or want the additional complexity.
Aside from that, the main advantage of this is transactions. I can do: begin; insert_row(); schedule_job_for_elasticsearch(); commit; And it's guaranteed that both the row and job for Elasticsearch update are inserted. If you use a dedicated queue system them this becomes a lot more tricky: begin; insert_row(); schedule_job_for_elasticsearch(); commit; // Can fail, and then we have a ES job but no SQL row. begin; ins…
Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
61–70 of 140 posts
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#62Earlier quoted context omitted.
Aside from that, the main advantage of this is transactions. I can do: begin; insert_row(); schedule_job_for_elasticsearch(); commit; And it's guaranteed that both the row and job for Elasticsearch update are inserted. If you use a dedicated queue system them this becomes a lot more tricky: begin; insert_row(); schedule_job_for_elasticsearch(); commit; // Can fail, and then we have a ES job but no SQL row. begin; ins…
Most of these two phase problems can be solved by having separate queue consumers. And as far as I can tell, this is only a perk when your two actions are mutate the collocated database and do X. For all other situations this seems like a downgrade.
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#63Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#64This looks like a great task queue, I'm a massive proponent of "Postgres is all you need" [0] and doubling down on it with my project that takes it to the extreme. What I would love is a Postgres task queue that does multi-step pipelines, with fan out and accumulation. In my view a structured relational database is a particularly good backend for that as it inherently can model the structure. Is that something you ha…
Putting low throughput queues in the same DB is great both for simplicity and for getting exactly-once-processing. Putting high throughput queues in Postgres sucks because... No O(1) guarantee to get latest job. Query planner can go haywire. High update tables bloat like crazy. Needs a whole new storage engine aka ZHEAP Write amplification as every update has to update every index LISTEN/NOTIFY doesn't work through c…
You can then delete the older rows when needed or as required.
Query planner issues are a general problem in postgres and is not unique to this problem. Not sure what O(1) means in this context. I am not sure pg has ever been able to promise constant-time access to anything; indeed, with an index, it'd never be asymptotically upper bounded as constant time at all?
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#65 update job_table set key=value where ... limit 1
It's simple and atomic. Unfortunately PG doesn't allow `update ... limit` syntaxRe: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#66I’ve been thinking about the potential for PostgreSQL-backed job queue libraries to share a common schema. For instance, I’m a big fan of Oban in Elixir: https://github.com/sorentwo/oban Given that there are many Sidekiq-compatible libraries across various languages, it might be beneficial to have a similar approach for PostgreSQL-based job queues. This could allow for job processing in different languages while main…
This would be so immensely useful. I’d estimate that there are so many cases where the producer is Node or Rails and the consumer is Python.
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#67This looks like a great task queue, I'm a massive proponent of "Postgres is all you need" [0] and doubling down on it with my project that takes it to the extreme. What I would love is a Postgres task queue that does multi-step pipelines, with fan out and accumulation. In my view a structured relational database is a particularly good backend for that as it inherently can model the structure. Is that something you ha…
I've come to hate "Postgres is all you need." Or at least, "a single Postgres database is all you need."
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#68The most simple job queue in MySQL: update job_table set key=value where ... limit 1 It's simple and atomic. Unfortunately PG doesn't allow `update ... limit` syntax
and almost certainly incorrect, gotta read at least https://www.pgcon.org/2016/schedule/attachments/414_queues-p... which discusses FOR UPDATE SKIP LOCKED
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#69Good Job does the same for Rails https://github.com/bensheldon/good_job
Re: Show HN: PgQueuer – Transform PostgreSQL into a Job Queue
#70The most simple job queue in MySQL: update job_table set key=value where ... limit 1 It's simple and atomic. Unfortunately PG doesn't allow `update ... limit` syntax
> It's simple and atomic and almost certainly incorrect, gotta read at least https://www.pgcon.org/2016/schedule/attachments/414_queues-p... which discusses FOR UPDATE SKIP LOCKED