FREEZE

FREEZE is a command used in SQL for databases, specifically in PostgreSQL. It is used to mark rows as frozen early in a transaction, thus reducing the need for future vacuuming operations.

Example

CREATE TABLE test (a INT);
INSERT INTO test VALUES (1), (2), (3), (4), (5);
VACUUM FREEZE test;
SELECT pg_frozen_xid_current();

Output

pg_frozen_xid_current
-----------------------
10000
(1 row)

Explanation

In the above code, a test table is created, and five integer records are inserted into the table. The VACUUM FREEZE test; command executes the FREEZE operation on the test table. The FREEZE operation marks all rows in the table as frozen, which means they will not be subject to transaction ID wraparound.

The SELECT pg_frozen_xid_current(); command is used to retrieve the current transaction ID, showing that the transaction has been frozen.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.