Re: Problem with displaying "wide" tables in psql

From: Sergey Muraviov <sergey(dot)k(dot)muraviov(at)gmail(dot)com>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Problem with displaying "wide" tables in psql
Date: 2013-12-05 06:09:47
Message-ID: CAJTaR32tcH6R3i1sB=uM0GycfcYHa4P0T4iVNc0dQn2Q-Wf9Tw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

And my patch affects the row view only.

postgres=# \x 1
postgres=# create table wide_table (value text);
postgres=# insert into wide_table values ('afadsafasd fasdf asdfasd fsad
fas df sadf sad f sadf sadf sa df sadfsadfasd fsad fsa df sadf asd fa sfd
sadfsadf asdf sad f sadf sad fadsf');
postgres=# insert into wide_table values ('afadsafasd fasdf asdfasd');
postgres=# select * from wide_table;
-[ RECORD 1
]-------------------------------------------------------------------
-------------------------------------------------------------------
value | afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf sadf sa df
sadfsad
fasd fsad fsa df sadf asd fa sfd sadfsadf asdf sad f sadf sad fadsf
-[ RECORD 2
]-------------------------------------------------------------------
-------------------------------------------------------------------
value | afadsafasd fasdf

If we add a new column to this table and put the border on, we can see that
all values in the table have the same width.

postgres=# alter table wide_table add column id integer;
postgres=# \pset border 2
postgres=# select * from wide_table;
+-[ RECORD 1
]------------------------------------------------------------------
----------------------------------------------------------------------+
| value | afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf sadf sa df
sadfs
adfasd fsad fsa df sadf asd fa sfd sadfsadf asdf sad f sadf sad fadsf |
| id |

|
+-[ RECORD 2
]------------------------------------------------------------------
----------------------------------------------------------------------+
| value | afadsafasd fasdf asdfasd

|
| id |

|
+-------+-----------------------------------------------------------------------
----------------------------------------------------------------------+

My patch tries to solve these problems:

-[ RECORD 1
]-------------------------------------------------------------------
value | afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf sadf sa df
sadfsad
fasd fsad fsa df sadf asd fa sfd sadfsadf asdf sad f sadf sad fadsf
-[ RECORD 2
]-------------------------------------------------------------------
value | afadsafasd fasdf asdfasd

and

+-[ RECORD 1
]-----------------------------------------------------------------+
| value | afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf sadf sa df
sadfs
adfasd fsad fsa df sadf asd fa sfd sadfsadf asdf sad f sadf sad fadsf
|
| id |
|
+-[ RECORD 2
]-----------------------------------------------------------------+
| value | afadsafasd fasdf asdfasd
|
| id |
|
+-------+----------------------------------------------------------------------+

Regards

2013/12/4 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>

> Hello
>
> postgres=# \pset format wrapped
> Output format (format) is wrapped.
> postgres=# select 'afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf
> sadf sa df sadfsadfasd fsad fsa df sadf asd fa sfd sadfsadf asdf sad f sadf
> sad fadsf';
>
> ?column?
>
> ---------------------------------------------------------------------------------------------------------------------
> afadsafasd fasdf asdfasd fsad fas df sadf sad f sadf sadf sa df
> sadfsadfasd fsad fsa df sadf asd fa sfd sadfsadf a.
> .sdf sad f sadf sad fadsf
> (1 row)
>
> It works as expected
>
> but it is not supported for row view. So any fix of this mode should be
> nice
>
> Regards
>
> Pavel
>
>
> 2013/12/4 Sergey Muraviov <sergey(dot)k(dot)muraviov(at)gmail(dot)com>
>
>> Thank you for this trick.
>> It would be nice if this trick was documented.
>>
>> However, with the pager I can't see wide value on one screen, select and
>> copy it entirely.
>> And I have to press many keys to find the necessary part of the value.
>> There is no such problems with the patch.
>>
>>
>> 2013/12/3 Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
>>
>>> Hello
>>>
>>> do you know a pager less trick
>>>
>>> http://merlinmoncure.blogspot.cz/2007/10/better-psql-with-less.html
>>>
>>> Regards
>>>
>>> Pavel Stehule
>>>
>>>
>>> 2013/12/3 Sergey Muraviov <sergey(dot)k(dot)muraviov(at)gmail(dot)com>
>>>
>>>> Hi.
>>>>
>>>> Psql definitely have a problem with displaying "wide" tables.
>>>> Even in expanded mode, they look horrible.
>>>> So I tried to solve this problem.
>>>>
>>>> Before the patch:
>>>> postgres=# \x 1
>>>> Expanded display (expanded) is on.
>>>> postgres=# \pset border 2
>>>> Border style (border) is 2.
>>>> postgres=# select * from pg_stats;
>>>>
>>>> +-[ RECORD 1
>>>> ]-----------+------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>>
>>>> --------------------------------------------------------------------------------
>>>> ----------------------------------------------------------+
>>>> | schemaname | pg_catalog
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> |
>>>> | tablename | pg_proc
>>>>
>>>> ...
>>>>
>>>> and after:
>>>>
>>>> +-[ RECORD 1
>>>> ]-----------+-----------------------------------------------------+
>>>> | schemaname | pg_catalog
>>>> |
>>>> | tablename | pg_proc
>>>> |
>>>> | attname | proname
>>>> |
>>>> | inherited | f
>>>> |
>>>> | null_frac | 0
>>>> |
>>>> | avg_width | 64
>>>> |
>>>> | n_distinct | -0.823159
>>>> |
>>>> | most_common_vals |
>>>> {max,min,overlaps,has_column_privilege,date_part,int4
>>>>
>>>> ,length,substring,sum,to_char,avg,int8,numeric,abs,generate_series,has_any_colum
>>>>
>>>> n_privilege,has_database_privilege,has_foreign_data_wrapper_privilege,has_functi
>>>>
>>>> on_privilege,has_language_privilege,has_schema_privilege,has_sequence_privilege,
>>>>
>>>> has_server_privilege,has_table_privilege,has_tablespace_privilege,has_type_privi
>>>>
>>>> lege,overlay,pg_has_role,point,stddev,stddev_pop,stddev_samp,text,time,timestamp
>>>>
>>>> tz,timezone,var_pop,var_samp,variance,age,float4,float8,int2,isfinite,pg_get_vie
>>>>
>>>> wdef,timestamp,bit_and,bit_or,mod,octet_length,polygon,substr,trunc,ts_headline,
>>>>
>>>> ts_rank,ts_rank_cd,area,bit,bit_length,box,bpchar,btrim,circle,date,date_trunc,i
>>>>
>>>> nterval,ishorizontal,isvertical,lag,lead,like,log,money,name,notlike,position,ro
>>>>
>>>> und,timetz,to_ascii,abbrev,abstime,array_fill,array_to_json,array_to_string,ceil
>>>>
>>>> ,ceiling,center,char,char_length,character_length,count,daterange,enum_range,exp
>>>>
>>>> ,floor,format,generate_subscripts,get_bit,gin_extract_tsquery,gin_extract_tsvect
>>>> or}
>>>> |
>>>> ...
>>>> | correlation | 0.254019
>>>> |
>>>> | most_common_elems |
>>>> |
>>>> | most_common_elem_freqs |
>>>> |
>>>> | elem_count_histogram |
>>>> |
>>>> +-[ RECORD 2
>>>> ]-----------+-----------------------------------------------------+
>>>> | schemaname | pg_catalog
>>>> |
>>>> | tablename | pg_proc
>>>> |
>>>> | attname | pronamespace
>>>> |
>>>> | inherited | f
>>>> |
>>>> | null_frac | 0
>>>> |
>>>> | avg_width | 4
>>>> |
>>>> | n_distinct | 2
>>>> |
>>>> | most_common_vals | {11,12410}
>>>> |
>>>> | most_common_freqs | {0.995274,0.00472627}
>>>> |
>>>> | histogram_bounds |
>>>> |
>>>> | correlation | 1
>>>> |
>>>> | most_common_elems |
>>>> |
>>>> | most_common_elem_freqs |
>>>> |
>>>> | elem_count_histogram |
>>>> |
>>>> +-[ RECORD 3
>>>> ]-----------+-----------------------------------------------------+
>>>>
>>>> Best regards,
>>>> Sergey Muraviov
>>>>
>>>>
>>>> --
>>>> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
>>>> To make changes to your subscription:
>>>> http://www.postgresql.org/mailpref/pgsql-hackers
>>>>
>>>>
>>>
>>
>>
>> --
>> Best regards,
>> Sergey Muraviov
>>
>
>

--
Best regards,
Sergey Muraviov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2013-12-05 06:22:59 Re: Re: [BUGS] BUG #7873: pg_restore --clean tries to drop tables that don't exist
Previous Message Jeff Davis 2013-12-05 05:39:56 Re: Extension Templates S03E11