HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Understanding Query Plan’s “width”

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
understandingquerywidthplan

Problem

The Douglas and Douglas PostgreSQL book includes the following EXPLAIN result:

The first step of the query, the Seq Scan, shows a width of 1917. However the last step of the query, the Sort, has a width of 1911.

Why/how could these values differ?

Solution

Every PostgreSQL row version (“tuple”) has a number of system columns and other data that are not displayed by SELECT * (see the documentation for details. Among them are

  • xmin and xmax



  • extra flags that contain the “hint bits” and the “frozen” flag.



  • ctid, the tuple's physical address.



These would account 23 bytes, not for four, so you'd have to look at tge source for more. The only of these items that occupies 6 bytes is ctid, so maybe that.

Context

StackExchange Database Administrators Q#241715, answer score: 3

Revisions (0)

No revisions yet.