N
The Daily Insight

What is Pg_xlog in PostgreSQL

Author

Isabella Browning

Updated on April 19, 2026

pg_xlog contains Postgres Write Ahead Logs (WAL, Postgres. implementation of transaction logging) files (normally 16MB in size, each). pg_clog contains the commit log files which contain transaction commit. status of a transaction.

What is in Pg_xlog directory?

At all the times, PostgreSQL maintains a write-ahead log (WAL) in the pg_xlog/ subdirectory of the cluster’s data directory. The log records for every change made to the database’s data files. These log messages exists primarily for crash-safety purposes.

What is a WAL segment?

A WAL segment is a 16 MB file, by default, and it is internally divided into pages of 8192 bytes (8 KB).

Is it safe to delete Pg_xlog?

$PGDATA/pg_xlog is the PostgreSQL transaction log. This set of binary log files, with names like ‘00000001000000000000008E’, contain images of the data from recent transactions. These logs are also used for binary replication. … Deleting pg_xlog files may result in unrecoverable database corruption.

What is WAL directory?

WAL logs are stored in the directory pg_xlog under the data directory, as a set of segment files, normally each 16 MB in size (but the size can be changed by altering the –with-wal-segsize configure option when building the server). …

Can I delete pg_wal?

pg_wal holds WAL files for the archiver to archive and hence is not deleting them, this will result in a disk full issue.

What is WAL files in PostgreSQL?

WAL is short for Write-Ahead-Log. Any change to the data is first recorded in a WAL file. The WAL files are mainly used by RDBMS as a way to achieve durability and consistency while writing data to storage systems.

What is Wal_keep_segments?

wal_keep_segments (integer) Specifies the minimum number of past log file segments kept in the pg_xlog directory, in case a standby server needs to fetch them for streaming replication. Each segment is normally 16 megabytes.

Where is Pg_wal?

WAL logs are stored in the directory pg_wal under the data directory, as a set of segment files, normally each 16 MB in size (but the size can be changed by altering the –wal-segsize initdb option).

How do I purge PGXLOG?

There are four approaches to doing so: removing non-WAL files to clear space, moving the pg_xlog directory, resizing the partition it is on, and removing some of the WAL files yourself. The easiest solution is to clear up space by removing any non-WAL files that are on the same partition.

Article first time published on

What is Wal_level in Postgres?

wal_level determines how much information is written to the WAL. The default value is minimal, which writes only the information needed to recover from a crash or immediate shutdown. … Each level includes the information logged at all lower levels. This parameter can only be set at server start.

What is WAL buffer in PostgreSQL?

WAL Buffers The write ahead log (WAL) buffers are also called “transaction log buffers”, which is an amount of memory allocation for storing WAL data. This WAL data is the metadata information about changes to the actual data, and is sufficient to reconstruct actual data during database recovery operations.

What is Checkpoint_segments in PostgreSQL?

18.5. checkpoint_segments (integer) Maximum number of log file segments between automatic WAL checkpoints (each segment is normally 16 megabytes). The default is three segments. Increasing this parameter can increase the amount of time needed for crash recovery. This parameter can only be set in the postgresql.

How does WAL work?

In computer science, write-ahead logging (WAL) is a family of techniques for providing atomicity and durability (two of the ACID properties) in database systems. … In a system using WAL, all modifications are written to a log before they are applied. Usually both redo and undo information is stored in the log.

What is recovery conf?

conf is a simple configuration file placed in the top level of the data directory which is used with standby servers to specify the location of the primary server for streaming replication, or when starting up a server using archived WAL files, or performing PITR.

What is a WAL file?

The write-ahead log or “wal” file is a roll-forward journal that records transactions that have been committed but not yet applied to the main database. Details on the format of the wal file are describe in the WAL format subsection of the main file format document.

What is Pg_archivecleanup?

pg_archivecleanup is designed to be used as an archive_cleanup_command to clean up WAL file archives when running as a standby server (see Section 26.2). … This minimizes the number of files that need to be retained, while preserving crash-restart capability.

What is Pg_xact?

pg_xact. Subdirectory containing transaction commit status data. postgresql.auto.conf. A file used for storing configuration parameters that are set by ALTER SYSTEM. postmaster.opts.

How do I clean my WAL Postgres?

WAL archives You can use the pg_archivecleanup command to remove WAL from an archive (not pg_xlog ) that’s not required by a given base backup. In general I suggest using PgBarman or a similar tool to automate your base backups and WAL retention though. It’s easier and less error prone.

Where is Pg_controldata?

Use locate pg_controldata to locate it at /usr/lib/postgresql/9.4/bin/pg_controldata . Alternatively, use find / -name pg_controldata .

What is hot standby in postgresql?

Hot Standby is the term used to describe the ability to connect to the server and run read-only queries while the server is in archive recovery or standby mode. This is useful both for replication purposes and for restoring a backup to a desired state with great precision.

What is streaming replication?

Streaming replication, a standard feature of PostgreSQL, allows the updated information on the primary server to be transferred to the standby server in real time, so that the databases of the primary server and standby server can be kept in sync.

How replication works in PostgreSQL?

Streaming replication in PostgreSQL works on log shipping. Every transaction in postgres is written to a transaction log called WAL (write-ahead log) to achieve durability. A slave uses these WAL segments to continuously replicate changes from its master.

What is Pgbench in PostgreSQL?

pgbench is a simple program for running benchmark tests on PostgreSQL. It runs the same sequence of SQL commands over and over, possibly in multiple concurrent database sessions, and then calculates the average transaction rate (transactions per second). … (In -T mode, only the actual number of transactions is printed.)

What is Work_mem in PostgreSQL?

work_mem is a configuration within Postgres that determines how much memory can be used during certain operations. At its surface, the work_mem setting seems simple: after all, work_mem just specifies the amount of memory available to be used by internal sort operations and hash tables before writing data to disk.

What is Pglogical?

pglogical is a logical replication system implemented entirely as a PostgreSQL extension. … This alternative to physical replication is a highly efficient method of replicating data using a publish/subscribe model for selective replication.

What are shared buffers?

Shared buffers are a pool of buffer space that the system can allocate dynamically across all of its ports as memory space is needed.

What is a shared memory buffer?

Shared memory is an operating-system feature that allows the database server threads and processes to share data by sharing access to pools of memory. … The buffer pool portion of shared memory contains the buffers that store dbspace pages that are read from disk.

What is Autovacuum in PostgreSQL?

Introduced in PostgreSQL 8.1, the AUTOVACUUM daemon is an optional feature that automatically vacuums the database so that you don’t have to manually run the VACUUM statement. … The AUTOVACUUM daemon is made up of multiple processes that reclaim storage by removing obsolete data or tuples from the database.

What is Checkpoint_completion_target?

checkpoint_completion_target is a configuration parameter specifying the fraction of the time between checkpoints which can elapse before a checkpoint is completed. checkpoint_completion_target was added in PostgreSQL 8.3.

What is Effective_cache_size?

The effective_cache_size parameter estimates how much memory is available for disk caching by the operating system and within the database itself. The PostgreSQL query planner decides whether it’s fixed in RAM or not.