
{"id":6506,"date":"2024-11-20T14:14:51","date_gmt":"2024-11-20T14:14:51","guid":{"rendered":"https:\/\/test.opensource-db.in\/wp1\/?p=6506"},"modified":"2024-11-21T05:24:53","modified_gmt":"2024-11-21T05:24:53","slug":"introduction-to-pg_repack-dealing-with-postgresql-bloat","status":"publish","type":"post","link":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/","title":{"rendered":"Introduction to pg_repack: Dealing with PostgreSQL bloat"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">PostgreSQL is a powerful and widely used relational database management system (RDBMS) known for its stability, scalability, and flexibility. However, over time, as data in PostgreSQL tables and indexes grows, performance can degrade due to fragmentation. This is where <code>pg_repack<\/code> comes in\u2014a tool that helps in reorganising and optimising your PostgreSQL database to improve performance without significant downtime.In this blog post, we\u2019ll cover what <code>pg_repack<\/code> is, its primary uses, and how to install and configure it for your PostgreSQL setup.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is <code>pg_repack<\/code>?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pg_repack<\/code> is an Open-source PostgreSQL extension designed to eliminate the bloat of table and index without requiring table locks or downtime. It removes bloat from tables and indexes and optionally restores clustered indexes&#8217; physical order. It works online without holding an exclusive lock on the processed tables during processing.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key Features of pg_repack<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Online Repacking<\/strong>: Unlike the traditional <code>VACUUM<\/code> or <code>REINDEX<\/code> commands in PostgreSQL, pg_repack works online, meaning it doesn\u2019t lock tables or indexes during the process. This makes it ideal for production environments where downtime is critical.<\/li>\n\n\n\n<li><strong>Index Rebuilding<\/strong>: pg_repack can rebuild indexes, removing fragmentation, and optimizing the storage for quicker access.<\/li>\n\n\n\n<li><strong>Table Repacking<\/strong>: It can also repack entire tables, reclaiming space occupied by dead tuples and reducing the size of the data files.<\/li>\n\n\n\n<li><strong>Database Repacking<\/strong>: In addition to individual tables and indexes, pg_repack can perform repacking on an entire database.<\/li>\n\n\n\n<li><strong>Space Savings<\/strong>: By reorganizing data and removing wasted space, pg_repack helps reduce the storage requirements of your PostgreSQL instance.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Common Uses of pg_repack<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some common scenarios where pg_repack can help:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Reducing Table Bloat<\/strong>: Over time, as data is inserted, updated, and deleted in tables, PostgreSQL&#8217;s internal storage can become fragmented. Repacking these tables can restore performance by removing unused space.<\/li>\n\n\n\n<li><strong>Rebuilding Indexes<\/strong>: Index fragmentation can slow down query performance. pg_repack rebuilds indexes in a way that eliminates fragmentation and optimizes query speed.<\/li>\n\n\n\n<li><strong>Improving Query Performance<\/strong>: By eliminating bloat in both tables and indexes, queries that rely on these objects will experience faster execution times due to reduced I\/O operations.<\/li>\n\n\n\n<li><strong>Reclaiming Disk Space<\/strong>: After a large number of DELETE operations or bulk updates, you may find that your database size doesn\u2019t shrink automatically. pg_repack can shrink the disk space used by these operations.<\/li>\n\n\n\n<li><strong>Running in Production with Minimal Impact<\/strong>: Since pg_repack works online, you can run the tool in a live production environment without locking tables for long periods. This is particularly useful for large, active databases.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Installation and Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The installation process for pg_repack is straightforward and depends on your operating system. Here are the steps to install on RHEL 9 running PG16.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;root@localhost ~]# yum install pg_repack_16\n#Check for the version to verify download\npg_repack --version <\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once the packages are installed, add <code>pg_repack<\/code> to <code>shared_preload_libraries<\/code> in <code>postgresql.conf<\/code> <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>shared_preload_libraries='pg_repack'\n#Restart the postgresql server\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After the restart , login to the database server and create the extension<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# create extension pg_repack;\nCREATE EXTENSION\npostgres=&gt; \\dx\n                                  List of installed extensions\n   Name    | Version |   Schema   |                         Description                          \n-----------+---------+------------+--------------------------------------------------------------\n pg_repack | 1.5.0   | public     | Reorganize tables in PostgreSQL databases with minimal locks\n plpgsql   | 1.0     | pg_catalog | PL\/pgSQL procedural language\n(2 rows)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Table<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a table named test with columns id (integer) and name (varchar with a maximum length of 250 characters). The id column is set as the primary key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# CREATE TABLE test (id int primary key, name varchar(250) );\nCREATE TABLE\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The table has been successfully created.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Insert 100,000 Rows<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">insert 100,000 rows into the test table.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# INSERT INTO test (id, name)\nSELECT\n    gs.id,\n    'name_' || gs.id AS name                                           \nFROM generate_series(1, 100000) AS gs(id);\nINSERT 0 100000<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">100,000 rows have been successfully inserted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check the Size of the Table<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After inserting the rows, check the size of the test table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# \\dt+\n                                   List of relations\n Schema | Name | Type  |  Owner   | Persistence | Access method |  Size   | Description \n--------+------+-------+----------+-------------+---------------+---------+-------------\n public | test | table | postgres | permanent   | heap          | 4360 kB | \n(1 row)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The size of the test table is 4360 kB.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Update All Rows<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Update all rows in the test table, setting the name column to &#8216;somename&#8217; for all records:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# update test set name ='somename';\nUPDATE 100000<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">100,000 rows have been updated.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the Size of the Table After Update<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# \\dt+\n                                   List of relations\n Schema | Name | Type  |  Owner   | Persistence | Access method |  Size   | Description \n--------+------+-------+----------+-------------+---------------+---------+-------------\n public | test | table | postgres | permanent   | heap          | 8688 kB | \n(1 row)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The size of the table has increased to 8688 kB.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Delete Rows<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# DELETE FROM test WHERE id BETWEEN 50000 AND 100000;\nDELETE 50001<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">50,001 rows have been deleted.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check the Size of the Table After Deletion<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After the deletion, check the size of the test table:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>postgres=# \\dt+\n                                   List of relations\n Schema | Name | Type  |  Owner   | Persistence | Access method |  Size   | Description \n--------+------+-------+----------+-------------+---------------+---------+-------------\n public | test | table | postgres | permanent   | heap          | 6520 kB | \n(1 row)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The size of the table is now 6520 kB.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using pg_repack to Reclaim Space in PostgreSQL.<br><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To reclaim space in a PostgreSQL table, you can use the pg_repack extension. Here&#8217;s the process to repack a table and check the space before and after the operation:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To repack the test table and reclaim the unused space<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;postgres@localhost ~]$ pg_repack --table=test -d postgres -e\nLOG: (query) SET search_path TO pg_catalog, pg_temp, public\nLOG: (query) SET search_path TO pg_catalog, pg_temp, public\nLOG: (query) select repack.version(), repack.version_sql()\nLOG: (query) SET statement_timeout = 0\nLOG: (query) SET search_path = pg_catalog, pg_temp, public\nLOG: (query) SET client_min_messages = warning\nLOG: (query) SELECT r FROM (VALUES ($1, 'r')) AS given_t(r,kind) WHERE NOT EXISTS(  SELECT FROM repack.tables WHERE relid=to_regclass(given_t.r)) AND NOT EXISTS(  SELECT FROM pg_catalog.pg_class c WHERE c.oid=to_regclass(given_t.r) AND c.relkind = given_t.kind AND given_t.kind = 'p')\nLOG: \t(param:0) = test\nLOG: (query) SELECT t.*, coalesce(v.tablespace, t.tablespace_orig) as tablespace_dest FROM repack.tables t,  (VALUES (quote_ident($1::text))) as v (tablespace) WHERE (relid = $2::regclass) ORDER BY t.relname, t.schemaname\nLOG: \t(param:0) = (null)\nLOG: \t(param:1) = test\nINFO: repacking table \"public.test\"\nLOG: (query) SELECT pg_try_advisory_lock($1, CAST(-2147483648 + $2::bigint AS integer))\nLOG: \t(param:0) = 16185446\nLOG: \t(param:1) = 25021\nLOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED\nLOG: (query) SET LOCAL lock_timeout = 100\nLOG: (query) LOCK TABLE public.test IN ACCESS EXCLUSIVE MODE\nLOG: (query) RESET lock_timeout\nLOG: (query) SELECT pg_get_indexdef(indexrelid) FROM pg_index WHERE indrelid = $1 AND NOT indisvalid\nLOG: \t(param:0) = 25021\nLOG: (query) SELECT indexrelid, repack.repack_indexdef(indexrelid, indrelid, $2, FALSE)  FROM pg_index WHERE indrelid = $1 AND indisvalid\nLOG: \t(param:0) = 25021\nLOG: \t(param:1) = (null)\nLOG: (query) SELECT repack.conflicted_triggers($1)\nLOG: \t(param:0) = 25021\nLOG: (query) SELECT repack.create_index_type(25024,25021)\nLOG: (query) SELECT repack.create_log_table(25021)\nLOG: (query) CREATE TRIGGER repack_trigger AFTER INSERT OR DELETE OR UPDATE ON public.test FOR EACH ROW EXECUTE PROCEDURE repack.repack_trigger('id')\nLOG: (query) ALTER TABLE public.test ENABLE ALWAYS TRIGGER repack_trigger\nLOG: (query) SELECT repack.disable_autovacuum('repack.log_25021')\nLOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED\nLOG: (query) SELECT pg_backend_pid()\nLOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'relation' AND granted = false AND relation = 25021 AND mode = 'AccessExclusiveLock' AND pid &lt;&gt; pg_backend_pid()\nLOG: (query) COMMIT\nLOG: (query) BEGIN ISOLATION LEVEL SERIALIZABLE\nLOG: (query) SELECT set_config('work_mem', current_setting('maintenance_work_mem'), true)\nLOG: (query) SELECT coalesce(array_agg(l.virtualtransaction), '{}')   FROM pg_locks AS l   LEFT JOIN pg_stat_activity AS a     ON l.pid = a.pid   LEFT JOIN pg_database AS d     ON a.datid = d.oid   WHERE l.locktype = 'virtualxid'   AND l.pid NOT IN (pg_backend_pid(), $1)   AND (l.virtualxid, l.virtualtransaction) &lt;&gt; ('1\/1', '-1\/0')   AND (a.application_name IS NULL OR a.application_name &lt;&gt; $2)  AND a.query !~* E'^\\\\s*vacuum\\\\s+'   AND a.query !~ E'^autovacuum: '   AND ((d.datname IS NULL OR d.datname = current_database()) OR l.database = 0)\nLOG: \t(param:0) = 41042\nLOG: \t(param:1) = pg_repack\nLOG: (query) DELETE FROM repack.log_25021\nLOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'relation' AND granted = false AND relation = 25021 AND mode = 'AccessExclusiveLock' AND pid &lt;&gt; pg_backend_pid()\nLOG: (query) SET LOCAL lock_timeout = 100\nLOG: (query) LOCK TABLE public.test IN ACCESS SHARE MODE\nLOG: (query) RESET lock_timeout\nLOG: (query) SELECT repack.create_table($1, $2)\nLOG: \t(param:0) = 25021\nLOG: \t(param:1) = pg_default\nLOG: (query) INSERT INTO repack.table_25021 SELECT id,name FROM ONLY public.test\nLOG: (query) SELECT repack.disable_autovacuum('repack.table_25021')\nLOG: (query) COMMIT\nLOG: (query) CREATE UNIQUE INDEX index_25024 ON repack.table_25021 USING btree (id)\nLOG: (query) SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)\nLOG: \t(param:0) = SELECT * FROM repack.log_25021 ORDER BY id LIMIT $1\nLOG: \t(param:1) = INSERT INTO repack.table_25021 VALUES ($1.*)\nLOG: \t(param:2) = DELETE FROM repack.table_25021 WHERE (id) = ($1.id)\nLOG: \t(param:3) = UPDATE repack.table_25021 SET (id, name) = ($2.id, $2.name) WHERE (id) = ($1.id)\nLOG: \t(param:4) = DELETE FROM repack.log_25021 WHERE id IN (\nLOG: \t(param:5) = 1000\nLOG: (query) SELECT pid FROM pg_locks WHERE locktype = 'virtualxid' AND pid &lt;&gt; pg_backend_pid() AND virtualtransaction = ANY($1)\nLOG: \t(param:0) = {}\nLOG: (query) SAVEPOINT repack_sp1\nLOG: (query) SET LOCAL lock_timeout = 100\nLOG: (query) LOCK TABLE public.test IN ACCESS EXCLUSIVE MODE\nLOG: (query) RESET lock_timeout\nLOG: (query) SELECT repack.repack_apply($1, $2, $3, $4, $5, $6)\nLOG: \t(param:0) = SELECT * FROM repack.log_25021 ORDER BY id LIMIT $1\nLOG: \t(param:1) = INSERT INTO repack.table_25021 VALUES ($1.*)\nLOG: \t(param:2) = DELETE FROM repack.table_25021 WHERE (id) = ($1.id)\nLOG: \t(param:3) = UPDATE repack.table_25021 SET (id, name) = ($2.id, $2.name) WHERE (id) = ($1.id)\nLOG: \t(param:4) = DELETE FROM repack.log_25021 WHERE id IN (\nLOG: \t(param:5) = 0\nLOG: (query) SELECT repack.repack_swap($1)\nLOG: \t(param:0) = 25021\nLOG: (query) COMMIT\nLOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED\nLOG: (query) SAVEPOINT repack_sp1\nLOG: (query) SET LOCAL lock_timeout = 100\nLOG: (query) LOCK TABLE public.test IN ACCESS EXCLUSIVE MODE\nLOG: (query) RESET lock_timeout\nLOG: (query) SELECT repack.repack_drop($1, $2)\nLOG: \t(param:0) = 25021\nLOG: \t(param:1) = 4\nLOG: (query) COMMIT\nLOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED\nLOG: (query) ANALYZE public.test\nLOG: (query) COMMIT\nLOG: (query) SELECT pg_advisory_unlock($1, CAST(-2147483648 + $2::bigint AS integer))\nLOG: \t(param:0) = 16185446\nLOG: \t(param:1) = 25021<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Checking the Table Size After Repacking<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">After the repack process completes, you can check the table size again:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\npostgres=# \\dt+\n                                   List of relations\n Schema | Name | Type  |  Owner   | Persistence | Access method |  Size   | Description \n--------+------+-------+----------+-------------+---------------+---------+-------------\n public | test | table | postgres | permanent   | heap          | 2192 kB | \n(1 row)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The size of the test table has reduced to 2192 kB, indicating that the unused space has been reclaimed, and the table&#8217;s storage has been optimized.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check and use the option available based on your requirement.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#091;postgres@localhost ~]$ pg_repack --help\npg_repack re-organizes a PostgreSQL database.\n\nUsage:\n  pg_repack &#091;OPTION]... &#091;DBNAME]\nOptions:\n  -a, --all                 repack all databases\n  -t, --table=TABLE         repack specific table only\n  -I, --parent-table=TABLE  repack specific parent table and its inheritors\n  -c, --schema=SCHEMA       repack tables in specific schema only\n  -s, --tablespace=TBLSPC   move repacked tables to a new tablespace\n  -S, --moveidx             move repacked indexes to TBLSPC too\n  -o, --order-by=COLUMNS    order by columns instead of cluster keys\n  -n, --no-order            do vacuum full instead of cluster\n  -N, --dry-run             print what would have been repacked\n  -j, --jobs=NUM            Use this many parallel jobs for each table\n  -i, --index=INDEX         move only the specified index\n  -x, --only-indexes        move only indexes of the specified table\n  -T, --wait-timeout=SECS   timeout to cancel other backends on conflict\n  -D, --no-kill-backend     don't kill other backends when timed out\n  -Z, --no-analyze          don't analyze at end\n  -k, --no-superuser-check  skip superuser checks in client\n  -C, --exclude-extension   don't repack tables which belong to specific extension\n\nConnection options:\n  -d, --dbname=DBNAME       database to connect\n  -h, --host=HOSTNAME       database server host or socket directory\n  -p, --port=PORT           database server port\n  -U, --username=USERNAME   user name to connect as\n  -w, --no-password         never prompt for password\n  -W, --password            force password prompt\n\nGeneric options:\n  -e, --echo                echo queries\n  -E, --elevel=LEVEL        set output message level\n  --help                    show this help, then exit\n  --version                 output version information, then exit\n\nRead the website for details: &lt;https:\/\/reorg.github.io\/pg_repack\/&gt;.\nReport bugs to &lt;https:\/\/github.com\/reorg\/pg_repack\/issues&gt;.<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>pg_repack<\/code> is a powerful tool for optimizing PostgreSQL databases by reducing fragmentation and reclaiming disk space. It helps maintain high performance in production systems by reorganizing tables and indexes online, with minimal impact on ongoing operations. By regularly running pg_repack, you can keep your database lean, fast, and efficient.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With its simple installation and straightforward usage, pg_repack is an essential tool for PostgreSQL administrators who want to ensure their databases remain performant as they grow. Whether you\u2019re working with a large, active database or a smaller, more static one, pg_repack can help you maintain optimal performance with minimal effort.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PostgreSQL is a powerful and widely used relational database management system (RDBMS) known for its stability, scalability, and flexibility. However, [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":6520,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[23,42,89],"tags":[],"class_list":["post-6506","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-postgresql-14","category-postgresql-15","category-postgresql-16"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB\" \/>\n<meta property=\"og:description\" content=\"PostgreSQL is a powerful and widely used relational database management system (RDBMS) known for its stability, scalability, and flexibility. However, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\" \/>\n<meta property=\"og:site_name\" content=\"OpenSource DB\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-20T14:14:51+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-21T05:24:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"945\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Shameer Bhupathi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@opensource_db\" \/>\n<meta name=\"twitter:site\" content=\"@opensource_db\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shameer Bhupathi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\"},\"author\":{\"name\":\"Shameer Bhupathi\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/422480fbefed0b2cee82aeab232110f5\"},\"headline\":\"Introduction to pg_repack: Dealing with PostgreSQL bloat\",\"datePublished\":\"2024-11-20T14:14:51+00:00\",\"dateModified\":\"2024-11-21T05:24:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\"},\"wordCount\":822,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png\",\"articleSection\":[\"PostgreSQL 14\",\"PostgreSQL 15\",\"PostgreSQL 16\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\",\"name\":\"Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB\",\"isPartOf\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png\",\"datePublished\":\"2024-11-20T14:14:51+00:00\",\"dateModified\":\"2024-11-21T05:24:53+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png\",\"contentUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png\",\"width\":1800,\"height\":945},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/test.opensource-db.in\/wp1\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Introduction to pg_repack: Dealing with PostgreSQL bloat\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#website\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/\",\"name\":\"OpenSource DB\",\"description\":\"Your Trusted OpenSource Databases partner\",\"publisher\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/test.opensource-db.in\/wp1\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#organization\",\"name\":\"OPENSOURCE DB PRIVATE LIMITED\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png\",\"contentUrl\":\"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png\",\"width\":368,\"height\":120,\"caption\":\"OPENSOURCE DB PRIVATE LIMITED\"},\"image\":{\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/\",\"https:\/\/x.com\/opensource_db\",\"https:\/\/www.youtube.com\/channel\/UCmTI5h\",\"https:\/\/www.linkedin.com\/company\/opensource-db\",\"https:\/\/www.instagram.com\/opensource_db\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/422480fbefed0b2cee82aeab232110f5\",\"name\":\"Shameer Bhupathi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2cfa95999202132ded07acd24f6faf25dca145a6c3efe47919204f115ffbf625?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2cfa95999202132ded07acd24f6faf25dca145a6c3efe47919204f115ffbf625?s=96&d=mm&r=g\",\"caption\":\"Shameer Bhupathi\"},\"url\":\"https:\/\/test.opensource-db.in\/wp1\/author\/shameer-bhupathi\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB","og_description":"PostgreSQL is a powerful and widely used relational database management system (RDBMS) known for its stability, scalability, and flexibility. However, [&hellip;]","og_url":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/","og_site_name":"OpenSource DB","article_publisher":"https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/","article_published_time":"2024-11-20T14:14:51+00:00","article_modified_time":"2024-11-21T05:24:53+00:00","og_image":[{"width":1800,"height":945,"url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png","type":"image\/png"}],"author":"Shameer Bhupathi","twitter_card":"summary_large_image","twitter_creator":"@opensource_db","twitter_site":"@opensource_db","twitter_misc":{"Written by":"Shameer Bhupathi","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#article","isPartOf":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/"},"author":{"name":"Shameer Bhupathi","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/422480fbefed0b2cee82aeab232110f5"},"headline":"Introduction to pg_repack: Dealing with PostgreSQL bloat","datePublished":"2024-11-20T14:14:51+00:00","dateModified":"2024-11-21T05:24:53+00:00","mainEntityOfPage":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/"},"wordCount":822,"commentCount":0,"publisher":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#organization"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage"},"thumbnailUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png","articleSection":["PostgreSQL 14","PostgreSQL 15","PostgreSQL 16"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/","url":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/","name":"Introduction to pg_repack: Dealing with PostgreSQL bloat - OpenSource DB","isPartOf":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#website"},"primaryImageOfPage":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage"},"thumbnailUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png","datePublished":"2024-11-20T14:14:51+00:00","dateModified":"2024-11-21T05:24:53+00:00","breadcrumb":{"@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#primaryimage","url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png","contentUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png","width":1800,"height":945},{"@type":"BreadcrumbList","@id":"https:\/\/test.opensource-db.in\/wp1\/introduction-to-pg_repack-dealing-with-postgresql-bloat\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/test.opensource-db.in\/wp1\/"},{"@type":"ListItem","position":2,"name":"Introduction to pg_repack: Dealing with PostgreSQL bloat"}]},{"@type":"WebSite","@id":"https:\/\/test.opensource-db.in\/wp1\/#website","url":"https:\/\/test.opensource-db.in\/wp1\/","name":"OpenSource DB","description":"Your Trusted OpenSource Databases partner","publisher":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/test.opensource-db.in\/wp1\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/test.opensource-db.in\/wp1\/#organization","name":"OPENSOURCE DB PRIVATE LIMITED","url":"https:\/\/test.opensource-db.in\/wp1\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/","url":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png","contentUrl":"https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2021\/10\/osdb-logo-tm-2.png","width":368,"height":120,"caption":"OPENSOURCE DB PRIVATE LIMITED"},"image":{"@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/people\/OpenSource-DB\/100072970755470\/","https:\/\/x.com\/opensource_db","https:\/\/www.youtube.com\/channel\/UCmTI5h","https:\/\/www.linkedin.com\/company\/opensource-db","https:\/\/www.instagram.com\/opensource_db\/"]},{"@type":"Person","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/422480fbefed0b2cee82aeab232110f5","name":"Shameer Bhupathi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/test.opensource-db.in\/wp1\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2cfa95999202132ded07acd24f6faf25dca145a6c3efe47919204f115ffbf625?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2cfa95999202132ded07acd24f6faf25dca145a6c3efe47919204f115ffbf625?s=96&d=mm&r=g","caption":"Shameer Bhupathi"},"url":"https:\/\/test.opensource-db.in\/wp1\/author\/shameer-bhupathi\/"}]}},"rttpg_featured_image_url":{"full":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",1800,945,false],"landscape":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",1800,945,false],"portraits":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",1800,945,false],"thumbnail":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13-150x150.png",150,150,true],"medium":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13-300x158.png",300,158,true],"large":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13-1024x538.png",1024,538,true],"1536x1536":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13-1536x806.png",1536,806,true],"2048x2048":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",1800,945,false],"ultp_layout_landscape_large":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",1200,630,false],"ultp_layout_landscape":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",870,457,false],"ultp_layout_portrait":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",600,315,false],"ultp_layout_square":["https:\/\/test.opensource-db.in\/wp1\/wp-content\/uploads\/2024\/11\/image-13.png",600,315,false]},"rttpg_author":{"display_name":"Shameer Bhupathi","author_link":"https:\/\/test.opensource-db.in\/wp1\/author\/shameer-bhupathi\/"},"rttpg_comment":0,"rttpg_category":"<a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-14\/\" rel=\"category tag\">PostgreSQL 14<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-15\/\" rel=\"category tag\">PostgreSQL 15<\/a> <a href=\"https:\/\/test.opensource-db.in\/wp1\/category\/postgres\/postgresql-16\/\" rel=\"category tag\">PostgreSQL 16<\/a>","rttpg_excerpt":"PostgreSQL is a powerful and widely used relational database management system (RDBMS) known for its stability, scalability, and flexibility. However, [&hellip;]","_links":{"self":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/6506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/comments?post=6506"}],"version-history":[{"count":8,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/6506\/revisions"}],"predecessor-version":[{"id":6523,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/posts\/6506\/revisions\/6523"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/media\/6520"}],"wp:attachment":[{"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/media?parent=6506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/categories?post=6506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/test.opensource-db.in\/wp1\/wp-json\/wp\/v2\/tags?post=6506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}