Re: very long record lines in expanded psql output

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Platon Pronko <platon7pronko(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: very long record lines in expanded psql output
Date: 2021-08-05 15:58:09
Message-ID: 998a8549-f808-a349-bae6-9f44d07e050d@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 8/5/21 6:56 AM, Pavel Stehule wrote:
> Hi
>
> čt 5. 8. 2021 v 12:36 odesílatel Platon Pronko
> <platon7pronko(at)gmail(dot)com <mailto:platon7pronko(at)gmail(dot)com>> napsal:
>
> In expanded mode psql calculates the width of the longest field in
> all the output rows,
> and prints the header line according to it. This often results in
> record header wrapping
> over several lines (see example below).
>
> This huge record header is printed the same way before each
> record, even if all the fields
> in current record are small and fit into terminal width. This
> often leads to situations
> when record header occupies the entirety of the screen, for all
> records, even though there are
> only a few records with huge fields in a record set.
>
> Maybe we can avoid making the header line longer than terminal
> width for \pset border 0
> and \pset border 1? We already have terminal width calculated.
> Please see attached a patch
> with the proposed implementation.
>
> Example output before the modification, in a terminal with a
> 100-column width:
>
> $ psql template1 -c "\x on" -c "\pset border 1;" -c "select n,
> repeat('x', n) as long_column_name from unnest(array[42,210]) as n"
> Expanded display is on.
> Border style is 1.
> ─[ RECORD 1
> ]────┬──────────────────────────────────────────────────────────────────────────────────
> ────────────────────────────────────────────────────────────────────────────────────────────────────
> ─────────────────────────────
> n                │ 42
> long_column_name │ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> ─[ RECORD 2
> ]────┼──────────────────────────────────────────────────────────────────────────────────
> ────────────────────────────────────────────────────────────────────────────────────────────────────
> ─────────────────────────────
> n                │ 210
> long_column_name │
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> And here's the same command after the patch:
>
> $ psql template1 -c "\x on" -c "\pset border 1;" -c "select n,
> repeat('x', n) as long_column_name from unnest(array[42,210]) as n"
> Expanded display is on.
> Border style is 1.
> ─[ RECORD 1
> ]────┬──────────────────────────────────────────────────────────────────────────────────
> n                │ 42
> long_column_name │ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> ─[ RECORD 2
> ]────┼──────────────────────────────────────────────────────────────────────────────────
> n                │ 210
> long_column_name │
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
>
> the length of lines should be consistent.
>
> Your proposal breaks pspg
>
> https://github.com/okbob/pspg <https://github.com/okbob/pspg>
>
> It can be separate option, but it should not be default
>
>

I also find this annoying and would be happy to be rid of it.  I could
see setting an option like

\pset xheader_width column|page|nnn

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Platon Pronko 2021-08-05 16:04:37 Re: very long record lines in expanded psql output
Previous Message Andrew Dunstan 2021-08-05 15:41:38 Re: Another regexp performance improvement: skip useless paren-captures