You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: ability to use unlogged table on Postgres (#1290)
* feat: ability to use unlogged table on Postgres
* feat: ability to use unlogged table on Postgres
* updating documentation
---------
Co-authored-by: Jared Wray <me@jaredwray.com>
By default, the adapter creates a logged table. If you want to use an unlogged table for performance, you can pass the `useUnloggedTable` option to the constructor.
From the [PostgreSQL documentation](https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED):
66
+
67
+
If specified, the table is created as an unlogged table. Data written to unlogged tables is not written to the write-ahead log (see Chapter 28), which makes them considerably faster than ordinary tables. However, they are not crash-safe: an unlogged table is automatically truncated after a crash or unclean shutdown. The contents of an unlogged table are also not replicated to standby servers. Any indexes created on an unlogged table are automatically unlogged as well.
68
+
69
+
If this is specified, any sequences created together with the unlogged table (for identity or serial columns) are also created as unlogged.
70
+
71
+
## Connection pooling
72
+
73
+
The adapter automatically uses the default settings on the `pg` package for connection pooling. You can override these settings by passing the options to the constructor such as setting the `max` pool size.
When testing you can use our `docker compose` postgresql instance by having docker installed and running. This will start a postgres server, run the tests, and stop the server:
letcreateTable=`CREATETABLE IF NOT EXISTS ${this.opts.schema!}.${this.opts.table!}(key VARCHAR(${Number(this.opts.keySize!)}) PRIMARY KEY, value TEXT )`;
49
+
letcreateTable=`CREATE${this.opts.useUnloggedTable ? ' UNLOGGED ' : ' '}TABLE IF NOT EXISTS ${this.opts.schema!}.${this.opts.table!}(key VARCHAR(${Number(this.opts.keySize!)}) PRIMARY KEY, value TEXT )`;
39
50
40
51
if(this.opts.schema!=='public'){
41
52
createTable=`CREATE SCHEMA IF NOT EXISTS ${this.opts.schema!}; ${createTable}`;
0 commit comments