Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are PostgreSQL temporary tables already unlogged?

I am working on a database operation, which produces a lot of inserts (~ 15,000,000).

I am currently using a temporary table for this data, because the data is no longer required after the operation. I recently found out, that unlogged tables have a better insert performance and hence I want to use it. But reading the documentation, it is not clear to me if temporary tables are already unlogged? And if they are not, is there a way to make them unlogged?

If I try to alter a temporary table like this:

alter table temp_table set unlogged;

I get the error: [42P16] ERROR: cannot change logged status of table "test" because it is temporary

like image 759
zingi Avatar asked Dec 09 '19 10:12

zingi


1 Answers

Temporary tables are never WAL logged.

Since they will be gone with the database session, there is never a need to recover them.

like image 115
Laurenz Albe Avatar answered Oct 17 '22 22:10

Laurenz Albe