Thread: Use or not record count on examples
There is no rule of when the number of records at the end of the lists should be shown or not
Sometimes we show that line "(4 rows)", but sometimes not.
Should we have a standard for it ? Should we add them all or remove them all ?
I think they are useless. Or maybe shown when no rows are returned.
datatype.sgml
a | char_length
------+-------------
ok | 2
------+-------------
ok | 2
name | current_mood
------+--------------
Moe | happy
(1 row)
------+--------------
Moe | happy
(1 row)
func.sgml
a | b
---+-----
1 | foo
2 |
---+-----
1 | foo
2 |
make | model | sales
-------+-------+-------
Foo | GT | 10
Foo | Tour | 20
Bar | City | 15
Bar | Sport | 5
(4 rows)
-------+-------+-------
Foo | GT | 10
Foo | Tour | 20
Bar | City | 15
Bar | Sport | 5
(4 rows)
Or maybe when not all records are shown, like in planstats.sgml
index | values | nulls | frequency | base_frequency
-------+----------+-------+-----------+----------------
0 | {0, 0} | {f,f} | 0.01 | 0.0001
1 | {1, 1} | {f,f} | 0.01 | 0.0001
...
49 | {49, 49} | {f,f} | 0.01 | 0.0001
50 | {50, 50} | {f,f} | 0.01 | 0.0001
...
97 | {97, 97} | {f,f} | 0.01 | 0.0001
98 | {98, 98} | {f,f} | 0.01 | 0.0001
99 | {99, 99} | {f,f} | 0.01 | 0.0001
(100 rows)
-------+----------+-------+-----------+----------------
0 | {0, 0} | {f,f} | 0.01 | 0.0001
1 | {1, 1} | {f,f} | 0.01 | 0.0001
...
49 | {49, 49} | {f,f} | 0.01 | 0.0001
50 | {50, 50} | {f,f} | 0.01 | 0.0001
...
97 | {97, 97} | {f,f} | 0.01 | 0.0001
98 | {98, 98} | {f,f} | 0.01 | 0.0001
99 | {99, 99} | {f,f} | 0.01 | 0.0001
(100 rows)
regards
Marcos
On Sun, 24 Nov 2024 at 01:30, Marcos Pegoraro <marcos@f10.com.br> wrote: > There is no rule of when the number of records at the end of the lists should be shown or not > Sometimes we show that line "(4 rows)", but sometimes not. > Should we have a standard for it ? Should we add them all or remove them all ? It looks like we have a few ways to try to trim down the query result output to save space on the page. In [1] we do: > SELECT format('|%10s|', 'foo'); > Result: | foo| I'm ok with the documentation being terse like this. If we were to standardise on something, that would likely force those examples to be much more verbose than they need to be. I don't think that verbosity would add any additional value. David [1] https://www.postgresql.org/docs/current/functions-string.html
Em dom., 24 de nov. de 2024 às 18:54, David Rowley <dgrowleyml@gmail.com> escreveu:
> SELECT format('|%10s|', 'foo');
This example you said returns one value, so I think it is ok.
I'm talking about lists with multiple fields or multiple lines. In [1] we have both modes.
I don't think that "(2 rows)" is useful
select jsonb_path_query(:'json', 'strict $.**.HR');
jsonb_path_query
------------------
73
135
jsonb_path_query
------------------
73
135
select jsonb_path_query(:'json', 'lax $.track.segments[*].location ?(@[*] > 15)');
jsonb_path_query
------------------
47.763
47.706
(2 rows)
jsonb_path_query
------------------
47.763
47.706
(2 rows)
There are lots of strange things related to this (... rows)
First, (0 rows) are completely useless. If no one record is shown, why do we need that list ?
We could change (0 rows), like this one on dblink.sgml
SELECT * FROM dblink_get_notify();
notify_name | be_pid | extra
-------------+--------+-------
(0 rows)
notify_name | be_pid | extra
-------------+--------+-------
(0 rows)
We could change it to
SELECT * FROM dblink_get_notify();<returnvalue>no rows returned</returnvalue>
Current version does not have these 19 rows as DOC says.
func.sgml
SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
...
(19 rows)
Show all settings counts 196 , but that is not true for current version.
show.sgml
SHOW ALL;
name | setting | description-------------------------+---------+-------------------------------------------------
allow_system_table_mods | off | Allows modifications of the structure of ...
.
.
.
xmloption | content | Sets whether XML data in implicit parsing ...
zero_damaged_pages | off | Continues processing past damaged page headers.
(196 rows)
Why do we need to show number of lines of explain ? I think all them could be removed
explain.sgml
EXPLAIN SELECT * FROM foo WHERE i = 4;
QUERY PLAN
--------------------------------------------------------------
Index Scan using fi on foo (cost=0.00..5.98 rows=1 width=4)
Index Cond: (i = 4)
(2 rows)
QUERY PLAN
--------------------------------------------------------------
Index Scan using fi on foo (cost=0.00..5.98 rows=1 width=4)
Index Cond: (i = 4)
(2 rows)
Please let me know if you agree with some of these changes and I can create a patch with that
regards
Marcos