Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List all UNLOGGED tables in Postgresql database

Since version 9.1, PostgreSQL supports the creation of UNLOGGED tables which do not use the WAL and are truncated during any DB recovery. See documentation: create unlogged table

Where does PostgreSQL store the information, whether a relation is UNLOGGED? I am looking for a query to list all relations that are UNLOGGED.

Thanks in advance

like image 670
alfonx Avatar asked Mar 14 '12 12:03

alfonx


People also ask

What are unlogged tables in PostgreSQL?

Unlogged tables is a PostgreSQL feature that can be used effectively to optimize bulk inserts. PostgreSQL uses Write-Ahead Logging (WAL). It provides atomicity and durability, by default. Atomicity, consistency, isolation, and durability make up the ACID properties.

How do I find the number of tables in PostgreSQL?

Use the \dt or \dt+ command in psql to show tables in a specific database. Use the SELECT statement to query table information from the pg_catalog.


2 Answers

It is the relpersistence column of the pg_class catalog:

http://www.postgresql.org/docs/9.1/static/catalog-pg-class.html

like image 105
Clodoaldo Neto Avatar answered Sep 23 '22 00:09

Clodoaldo Neto


https://www.postgresql.org/docs/current/catalog-pg-class.html

select relname, relowner from pg_class where relpersistence='u';
like image 37
Vivek Tripathy Avatar answered Sep 25 '22 00:09

Vivek Tripathy