NikolayS / postgres_dba

The missing set of useful tools for Postgres DBAs and all engineers
BSD 3-Clause "New" or "Revised" License
1.03k stars 113 forks source link

Issue of p1 #38

Open nemfir opened 5 years ago

nemfir commented 5 years ago

Good evening, Nikolay. Thank you for tool.

Report P1 confused me. Where I'm wrong? t1 it my table originally, t2 is offered.

https://dbfiddle.uk/?rdbms=postgres_11&fiddle=cc993fad2ccc51ba6bd410612f920849 https://dbfiddle.uk/?rdbms=postgres_11&fiddle=099342ecdd74af9fd50f680e57f631bb

NikolayS commented 4 years ago

Sorry for the delay with this answer @cttr-dev.

I'm looking at t1 table and the current implementation of report p1 – here is what it shows:

 Table | Table Size |     Comment      |     Wasted *     | Suggested Columns Reorder
-------+------------+------------------+------------------+---------------------------
 t1    | 8192 bytes | Includes VARLENA | ~8 bytes (0.10%) | c1, c10, c11             +
       |            |                  |                  | c12, c13, c14            +
       |            |                  |                  | c15, c16, c17            +
       |            |                  |                  | c18, c19, c2             +
       |            |                  |                  | c20, c3, c4              +
       |            |                  |                  | c5, c6, c7               +
       |            |                  |                  | c8, c9, c0               +
       |            |                  |                  | c00
(1 row)

In this situation, I wouldn't bother with column reordering -- the forecasted "waste" is <1%, so the layout is already pretty much optimized (you're using 8-byte columns first, so no alignment padding gaps in the beginning).