What happens to the memory after you delete a record with a varchar type in postgresql?

I understood the difference between char and varchar data types in postgresql . I clear that when you update a tuple in a varchar record is deleted from the disk and fit into a new place in memory . but what happens to freed memory location?
stayed at my example, 4 bytes in memory , and what is going to happen with them? they are again filled with string in 4 bytes?in my opinion it is inefficient for speed. Or they just stay empty?

P. s tell me more program for viewing occupied by the process of memory on the hard disk and RAM
March 23rd 20 at 19:42
1 answer
March 23rd 20 at 19:44
I SSS , at update of a tuple in a varchar record is deleted from the disk and fit into a new place in memory

Mmm. I doubt that is really something clear.

To start:
on the drive data exists in the same form, and then processed in memory. As a side result of this, by the way, the postgresql database is physically not portable to other processor architectures, only dump/restore or some other logical replication. And then there are the fun focus of the alignment data structures in memory. Why the different order of the columns in the table is identical to the volume of recorded data may vary in required disk space.

postgresql mvcc database. When a row is deleted the record is not deleted. At all. Only stamped xmax and the page is marked dirty. A refresh operation of the row does not exist. Update is always a delete + insert. Updated record in this case falls into a different table so that the table at the same time, there are old and new versions of the row. And they can be a lot.
(enterprisedb threatening to finish zheap in pg13, so maybe it's more fun, but in versions prior to 11 are guaranteed as I have described, in 12 only if you are a brave man and will collect experimental extensions)
So, next comes autovacuum or vacuum, lines which no one may be visible are cleaned and are considered to be empty space, including free space map.

Writing operations are trying to find a place on the record:
- in the same data page
- in a page starting from the beginning of the table
- in the worst case create a new page

Yes, maybe what is left of the region in datafile in which nothing and even nothing helpful there and will not fit.

occupied by the process of memory on the hard disk

What is it?
If you are interested in the format of dataflow something you value in the source database. OS allocates disk blocks at 8KB and they kept some kind of binary thing.

About private memory and find out - in postgresql there is a memory Manager call memory context. backend memory requests from the OS blocks, doing something that he needs using this memory for every detail or not detail, then memory context is reset or deleted and the memory returned to the OS. Most contexts do not exist long, for a transaction or query, for example.
The widely distributed debugger, gdb. No dbg build, however, there is clearly nothing will be clear.

Find more questions by tags PostgreSQL