zerodha / dungbeetle

A highly opinionated, distributed job-queue built specifically for queuing and executing heavy SQL read jobs asynchronously. Supports MySQL, Postgres, ClickHouse.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use Unlogged Tables in PostgreSQL

fabriziomello opened this issue · comments

Unlogged Tables was first introduced at PostgreSQL 9.1. From release notes:

  • Support unlogged tables using the UNLOGGED option in CREATE TABLE (Robert Haas)

Such tables provide better update performance than regular tables, but are not crash-safe: their contents are automatically cleared in case of a server crash. Their contents do not propagate to replication slaves, either.

Wonder if can can add this statement here https://github.com/knadh/sql-jobber/blob/master/backends/sqldb.go#L282 ? And perhaps add a new config option unlogged = true that works just for dbType=postgres

@fabriziomello yep, makes sense for this to be a config option unlogged = true/false. To carry this config through, it might make sense to refactor NewSQLBackend() a backends.Opt{} instead of the two individual dbType, resTable params, along with the new unlogged bool.

Edit: Woops, just saw the PR #14. If you could incorporate this as a config setting, that'd be perfect.

@knadh Pushed another version with proposed refactoring