Skip to content

Commit

Permalink
Merge pull request #5464 from EnterpriseDB/docs/pg_squeeze/lock-levels
Browse files Browse the repository at this point in the history
Added information about lock levels to pg_squeeze docs
  • Loading branch information
dwicinas authored Apr 3, 2024
2 parents fc5eb70 + 0a8502b commit c953c88
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion advocacy_docs/pg_extensions/pg_squeeze/using.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,34 @@ title: Using pg_squeeze
navTitle: Using
---

Use `pg_squeeze` to remove unused space from a table and optionally sort tuples according to a particular index.

## Understanding lock levels while using `pg_squeeze`

While using `pg_squeeze`, the extension performs a series of actions, and some of these actions place a lock on the squeezed table, as described in the following steps. The table being squeezed is available for both read and write operations by other transactions most of the time.

When squeezing a table, the extension:

1. Creates a transient table and copies the contents of the source table using the snapshot.

`pg_squeeze` holds an `ACCESS SHARE` lock on the source table during this step.

1. Builds indexes on the transient table.

`pg_squeeze` holds an `ACCESS SHARE` lock on the source table during this step.

1. Decodes and applies the concurrent changes that occurred on the source table while the initial load is in progress.

1. Applies any concurrent changes that take place while waiting for the lock and swaps the storage of the transient and the source table.

`pg_squeeze` holds an `ACCESS EXCLUSIVE` lock for a short period during this step.

1. Drops the transient table.


## Registering a table for regular processing

First, ensure that your table has either a primary key or a unique constraint. This is necessary to process changes resulting from other transactions while `pg_squeeze` is doing its work.
Before using `pg_squeeze`, ensure that your table has either a primary key or a replica identity. This is necessary to process changes resulting from other transactions while `pg_squeeze` is doing its work.

To make the `pg_squeeze` extension aware of the table, you must insert a record into the `squeeze.tables` table. After it is added, table statistics are checked periodically. When the table meets the necessary criteria to be squeezed, a task is added to a queue. The tasks are processed sequentially, in the order they are created.

Expand Down

1 comment on commit c953c88

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.