8

I am considering log-shipping of Write Ahead Logs (WAL) in PostgreSQL to create a warm-standby database. However I have one table in the database that receives a huge amount of INSERT/DELETEs each day, but which I don't care about protecting the data in it. To reduce the amount of WALs produced I was wondering, is there a way to prevent any activity on one table from being recorded in the WALs?

4 Answers 4

12

Ran across this old question, which now has a better answer. Postgres 9.1 introduced "Unlogged Tables", which are tables that don't log their DML changes to WAL. See the docs for more info, but at least now there is a solution for this problem.

See Waiting for 9.1 - UNLOGGED tables by depesz, and the 9.1 docs.

4
  • In versions before 9.1, if you truncate the table before doing the inserts, those inserts are not WAL logged either.
    – user330315
    Oct 29, 2011 at 14:48
  • I believe that's only true if you do the truncate/insert within the same transaction, but more importantly not applicable to the case with a warm standby, where the insert data still has to go into the WAL stream to get shipped to the other server.
    – xzilla
    Oct 29, 2011 at 15:02
  • You are correct about the transaction (I thought that was self-evident ;) ) Good point about the warm-standby though.
    – user330315
    Oct 29, 2011 at 16:10
  • ALTER TABLE mytable SET UNLOGGED Oct 29, 2018 at 22:34
6
+50

Unfortunately, I don't believe there is. The WAL logging operates on the page level, which is much lower than the table level and doesn't even know which page holds data from which table. In fact, the WAL files don't even know which pages belong to which database.

You might consider moving your high activity table to a completely different instance of PostgreSQL. This seems drastic, but I can't think of another way off the top of my head to avoid having that activity show up in your WAL files.

0

To offer one option to my own question. There are temp tables - "temporary tables are automatically dropped at the end of a session, or optionally at the end of the current transaction (see ON COMMIT below)" - which I think don't generate WALs. Even so, this might not be ideal as the table creation & design will be have to be in the code.

1
  • 1
    Temp tables will generate WAL entries for system catalog updates (pg_class) even if they don't for data updates (I'm not sure). You could move the busy table elsewhere and use the dblink interface to access it or switch to a table-based replication system like Slony.
    – mjy
    Dec 25, 2008 at 12:34
-5

I'd consider memcached for use-cases like this. You can even spread the load over a bunch of cheap machines too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.