2ndQuadrant is now part of EDB

Bringing together some of the world's top PostgreSQL experts.

2ndQuadrant | PostgreSQL
Mission Critical Databases
  • Contact us
  • Support & Services
    • Support
      • 24/7 PostgreSQL Support
      • Developer Support
    • DBA Services
      • Remote DBA
      • Database Monitoring
    • Consulting Services
      • Health Check
      • Performance Tuning
      • Database Security Audit
      • PostgreSQL Upgrade
    • Migration Services
      • Migrate to PostgreSQL
      • Migration Assessment
  • Products
    • Postgres-BDR ®
    • PostgreSQL High Availability
    • Kubernetes Operators for BDR & PostgreSQL
    • Managed PostgreSQL in the Cloud
    • Installers
      • Postgres Installer
      • 2UDA
    • 2ndQPostgres
    • pglogical
    • Barman
    • repmgr
    • OmniDB
    • SQL Firewall
    • Postgres-XL
  • Downloads
    • Installers
      • Postgres Installer
      • 2UDA – Unified Data Analytics
    • Whitepapers
      • Business Case for PostgreSQL Support
      • AlwaysOn Postgres
      • PostgreSQL with High Availability
      • Security Best Practices
      • BDR
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
  • Postgres Learning Center
    • Webinars
      • Upcoming Webinars
      • Webinar Library
    • Whitepapers
      • Business Case for PostgreSQL Support
      • AlwaysOn Postgres
      • PostgreSQL with High Availability
      • Security Best Practices
      • BDR
    • Blog
    • Training
      • Course Catalogue
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
    • Books
      • PostgreSQL 11 Administration Cookbook
      • PostgreSQL 10 Administration Cookbook
      • PostgreSQL High Availability Cookbook – 2nd Edition
      • PostgreSQL 9 Administration Cookbook – 3rd Edition
      • PostgreSQL Server Programming Cookbook – 2nd Edition
      • PostgreSQL 9 Cookbook – Chinese Edition
    • Videos
    • Events
    • PostgreSQL
      • PostgreSQL – History
      • Who uses PostgreSQL?
      • PostgreSQL FAQ
      • PostgreSQL vs MySQL
      • The Business Case for PostgreSQL
      • Security Information
      • Documentation
  • About Us
    • About 2ndQuadrant
    • What Does “2ndQuadrant” Mean?
    • 2ndQuadrant’s Passion for PostgreSQL
    • News
    • Careers
    • Team Profile
  • Blog
  • Menu Menu
You are here: Home1 / Blog2 / Webinars3 / Webinar: MVCC and Vacuum Basics in PostgreSQL [Follow Up]
MVCC and Vacuum Basics in PostgreSQL
Bilal Ibrar

Webinar: MVCC and Vacuum Basics in PostgreSQL [Follow Up]

May 8, 2020/0 Comments/in Webinars /by Bilal Ibrar

PostgreSQL uses MVCC to handle concurrent clients through snapshots instead of locks. This lets the server handle a larger transaction load and allows for a rich set of tools for developers to access data concurrently.

In order to get a deeper understanding of MVCC and Vacuum basics in PostgreSQL, as well as the pros and cons that come from its usage, 2ndQuadrant hosted a live webinar, MVCC and Vacuum Basics in PostgreSQL. 

The webinar was presented by Martín Marqués (Deputy Head of Support at 2ndQuadrant), in which he covered the following topics:

  • Overview of MVCC
  • What “xmin” and “xmax” system columns store?
  • Usage of “VACUUM” for clean up
  • “autovacuum” for automated clean-up
  • Visibility of rows, frozen rows and “VACUUM FREEZE”

Those who weren’t able to attend the live webinar can now view the recording here.

Due to limited time, some of the questions were not answered during the live webinar, so answers by the host are provided below:


Question: Is a deleted row the same as a frozen row?

Answer: No. A deleted row is one that is not visible for new sessions. A frozen row is one that is visible to all sessions.

 

Question: We have a small table (fixed 500 rows) and 50 updates per second. What is your recommendation/parameters for vacuuming this table?

Answer: That really depends. But you might want to fix in zero autovacuum_vacuum_scale_factor and give autovacuum_vacuum_threshold a fixed value larger than 50 so that a vacuum is executed every few minutes the table gets vacuumed. Make the vacuum very aggressive so it finishes quickly.

 

Question: We have a table of 1 billion rows and an hourly batch process inserting 5 million rows. What is your recommendation/parameters for vacuuming this table?

Answer: If the table only grows with inserts, what is needed is to keep the stats updated. Tune analyze so it runs more often.

 

Question: Regarding freeze, how can we check the progress of a running auto vacuum/vacuum freeze? 

Answer: If you are on one of the latest releases of Postgres, you can see the progress of the vacuum using pg_stat_progress_vacuum.

 

Question: Does vacuum also need to be performed on the system catalog?

Answer: Yes, catalog tables are just like user tables and get vacuumed. They are normally small and don’t have indexes, so vacuum finishes quickly.

 

Question: For the auto vacuum daemon, is it better to have more vacuum workers (autovacuum_max_workers) with less memory (maintenance_work_mem) or fewer workers with more memory allocated to them?

Answer: It’s advisable not to increase autovacuum_max_workers to value larger than 6. It’s better to have fewer workers that run quickly (low cost_delay) so that another worker can vacuum another table afterward.

 

Question: Reference the second example you showed (xmin 3004 and 3008), inside a transaction when you run the update query “update pp set ts=…where id%2=0”, should id 2,4 has the same ts? Since they are in the same transaction so ts time should be the same, but the slice shows 14:18:55 18724-03 and 14:18:55 187276-03 difference.

Answer: That is because I didn’t use now() which returns the time at the beginning of the transaction, but instead used clock_timestamp() which changes during execution.

 

Question: Does freezing tuples help with performance?

Answer: Freeze by itself will not affect performance, but the vacuum that freezes tuples will also clean up dead tuples.


To be the first to know about upcoming PostgreSQL webinars by 2ndQuadrant, visit our Webinars page.

For any questions, comments, or feedback, please visit our website or send an email to [email protected].

Tags: mvcc, PostgreSQL, webinars
Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Get in touch with us!

Recent Posts

  • Random Data December 3, 2020
  • Webinar: COMMIT Without Fear – The Beauty of CAMO [Follow Up] November 13, 2020
  • Full-text search since PostgreSQL 8.3 November 5, 2020
  • Random numbers November 3, 2020
  • Webinar: Best Practices for Bulk Data Loading in PostgreSQL [Follow Up] November 2, 2020

Featured External Blogs

Tomas Vondra's Blog

Our Bloggers

  • Simon Riggs
  • Alvaro Herrera
  • Andrew Dunstan
  • Craig Ringer
  • Francesco Canovai
  • Gabriele Bartolini
  • Giulio Calacoci
  • Ian Barwick
  • Marco Nenciarini
  • Mark Wong
  • Pavan Deolasee
  • Petr Jelinek
  • Shaun Thomas
  • Tomas Vondra
  • Umair Shahid

PostgreSQL Cloud

2QLovesPG 2UDA 9.6 backup Barman BDR Business Continuity community conference database DBA development devops disaster recovery greenplum Hot Standby JSON JSONB logical replication monitoring OmniDB open source Orange performance PG12 pgbarman pglogical PG Phriday postgres Postgres-BDR postgres-xl PostgreSQL PostgreSQL 9.6 PostgreSQL10 PostgreSQL11 PostgreSQL 11 PostgreSQL 11 New Features postgresql repmgr Recovery replication security sql wal webinar webinars

Support & Services

24/7 Production Support

Developer Support

Remote DBA for PostgreSQL

PostgreSQL Database Monitoring

PostgreSQL Health Check

PostgreSQL Performance Tuning

Database Security Audit

Upgrade PostgreSQL

PostgreSQL Migration Assessment

Migrate from Oracle to PostgreSQL

Products

HA Postgres Clusters

Postgres-BDR®

2ndQPostgres

pglogical

repmgr

Barman

Postgres Cloud Manager

SQL Firewall

Postgres-XL

OmniDB

Postgres Installer

2UDA

Postgres Learning Center

Introducing Postgres

Blog

Webinars

Books

Videos

Training

Case Studies

Events

About Us

About 2ndQuadrant

What does 2ndQuadrant Mean?

News

Careers 

Team Profile

© 2ndQuadrant Ltd. All rights reserved. | Privacy Policy
  • Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
Security and Compliance with PostgreSQL [Webinar] Security and Compliance with PostgreSQL [Webinar] Keep your libraries updated and nobody gets hurt Keep your libraries updated and nobody gets hurt
Scroll to top
×