Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the physical storage structure, version control and space recovery of PG

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to understand PG's physical storage structure, version control, space recycling," interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to understand PG's physical storage structure, version control, space recovery"!

Physical storage structure of PG

A table is organized in heap form, as distinct from mysql's clustered index.

2. Version control of PG

There are two ways to implement MVCC:

1) When writing data, move the old data to a separate place, such as in the rollback segment, and read the old data back from the rollback segment.

2) When writing data, the old data is not deleted, but new data is inserted, and the old data is written to the file.

MySQL, Oracle basically operates in the first way, while PostGres operates in the second way,

Disadvantages to the first: older versions of blocks need to be cleaned up, older versions of data because accessing files may cause I/O and scanning more blocks,

Advantages: Data can be updated a lot, do not worry about no rollback segment or rollback segment can not fit data,

Things roll back instantly, no matter how many operations things take place,

Several important terms are introduced for multiversion concurrency, implicit fields in the table:

oid tableoid ctid xmin xmax cmin cmax The last four fields control whether the data row is visible to the user

3. space reclamation

vacuum tidying up space

At this point, I believe that everyone has a deeper understanding of "how to understand PG's physical storage structure, version control, space recycling," so let's actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report