Subject: What is paging my psql

From: lejeczek <[email-masked]>
Date: Thu, 20 Nov 2025 15:16:35 +0100

Hi guys.

I have virtually identical 3 servers and one is paging the 
output.

-> $ psql --port=5437 -c '\pset pager'
Pager usage is off.

there is no PAGER nor any other, obvious OS evn var set, yet 
I do simple query which shows a few lines, eg.
-> $ psql --port=5437 --dbname=upa_discourse -c 'select * 
from pg_extension;'

and the output is paged, waiting for 'q' from user to go 
back to shell.
I could not find any psqlrc neither - and the other two 
servers do not that, to make more bizarre.
Would you know where is it coming from and how to fix it 
permanently - ideally not by adding stuff but by figuring 
out why it is the two servers do page and then fixing the 
odd one same way.
I'm on Ubuntu 22.04 with ver 16 of PG.

thanks, L.

---

From: "David G. Johnston" <[email-masked]>
Date: Thu, 20 Nov 2025 08:36:10 -0600

On Thursday, November 20, 2025, lejeczek <[email-masked]> wrote:
>
>
> I have virtually identical 3 servers and one is paging the output.
>

You just demonstrated that the psql running on this client uses the pager
by default.  Since by executing pset pager you turned it off.

The server being connected to should not play a role.  You’ll need a better
example if you claim otherwise.

David J.

---

From: Laurenz Albe <[email-masked]>
Date: Thu, 20 Nov 2025 20:02:12 +0100

On Thu, 2025-11-20 at 15:16 +0100, lejeczek wrote:
>  Would you know where is it coming from and how to fix it permanently

It is probably on by default.

Set the environment variable PAGER to an empty string.

Yours,
Laurenz Albe

---

From: lejeczek <[email-masked]>
Date: Fri, 21 Nov 2025 10:40:21 +0100

All three servers show the same:
-> $ psql --port=5437 -c '\pset' | egrep -i pager
pager                    1
pager_min_lines          0

Two of them do not page the query I showed

-> $ psql --port=5438 --dbname=yja_discourse -c 'select * 
from pg_extension;'
   oid  | extname  | extowner | extnamespace | 
extrelocatable | extversion | extconfig | extcondition
-------+----------+----------+--------------+----------------+------------+-----------+--------------
  13545 | plpgsql  |       10 |           11 | f            
   | 1.0        |           |
  16393 | hstore   |       10 |         2200 | t            
   | 1.8        |           |
  16521 | pg_trgm  |       10 |         2200 | t            
   | 1.6        |           |
  16602 | unaccent |       10 |         2200 | t            
   | 1.1        |           |
  61507 | vector   |       10 |         2200 | t            
   | 0.8.1      |           |
(5 rows)

third server pages - waits for user 'q' to switch back to 
shell prompt.
None of the servers - no that I could find - has $PAGER nor 
$PSQL_PAGER nor $SYSTEMD_PAGER set.
In fact:

-> $ set | egrep -i page
-> $ env | egrep -i page

shows nothing.
None of the servers - I failed to find - has psqlrc, not for 
the user nor system-wide.
On the two non-paging servers with this:
-> $ psql --port=5437 -c '\pset pager on'
Pager is used for long output.

done, the above query does not page - for the output is not 
long enough I believe.
On the third paging server - that does not change behaviour 
neither.
But I also noticed that after 'on/off' - this does not 
change and remains:
-> $ psql --port=5437 -c '\pset' | egrep -i pager
pager                    1
pager_min_lines          0

Should that change/setting not be permanent, at least for 
the session-time being?

thanks, L.

---

From: lejeczek <[email-masked]>
Date: Fri, 21 Nov 2025 10:43:36 +0100

neither any shell aliases involving psql exist

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 21 Nov 2025 07:34:07 -0600

> -> $ psql --port=5437 -c '\pset' | egrep -i pager

Everything seems to be working as intended.  You just seem to have
incorrect expectations.

Whether the pager is used is conditioned on actual output data.

pset controls client settings and those are never “saved”.  They have their
default values and a psqlrc file if you wish to change them during program
startup.

David J.

---

From: Tom Lane <[email-masked]>
Date: Fri, 21 Nov 2025 10:16:11 -0500

> Whether the pager is used is conditioned on actual output data.

IIRC, you can do "\pset pager always" if you want the pager to be
invoked regardless of the query output length.

Be aware though that the default pager is "more", which (at least
on my Linux box) silently does nothing special if the output is less
than a screenful.  If the behavior you are looking for is "wait for
a keystroke even after very short output", you'd need to combine the
\pset setting with "export PSQL_PAGER=less" or similar.

			regards, tom lane

---

From: lejeczek <[email-masked]>
Date: Fri, 21 Nov 2025 18:55:21 +0100

gee zuss boy...
I at this point begin to wonder if you guys - those who 
replied - even read what I/people say or.. you just take the 
piss.
I've only been trying to show that three boxes I have, with 
virtually the same settings, same env, same (absent!) shell 
vars, behave differently when they show _same_ output for 
the _same_ simple query.

What expectations? expectations about what?

I'm only trying to investigate & understand why that is that 
one box does - what I under is "paging" of a short output - 
whereas other two do _not_ that.
The _but_ here is - obviously - that between that 1 box VS 2 
other boxes, there must be a difference(s) somewhere... but 
! where?

thanks, L.

---

From: Tom Lane <[email-masked]>
Date: Fri, 21 Nov 2025 13:55:22 -0500

> vars, behave differently when they show _same_ output for 

[ shrug... ] So there is something different about those boxes.
We have less information about that than you do.  Have you
checked ~/.psqlrc on all three?

			regards, tom lane

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 21 Nov 2025 13:15:29 -0600

On Friday, November 21, 2025, lejeczek <[email-masked]> wrote:
>
> I'm only trying to investigate & understand why that is that one box does
> - what I under is "paging" of a short output - whereas other two do _not_
> that.
> The _but_ here is - obviously - that between that 1 box VS 2 other boxes, there
> must be a difference(s) somewhere... but ! where?
>

I guess I’m not trying to walk you through debugging and diagnostics at
this point because this doesn’t seem like a bug.  So yes, I’ve have been
unable to completely understand the issue because it is not being presented
in a complete manner.  It would be better to pick a single one that is
“wrong”, fully show and describe what you are doing and what you expect to
happen (and ideally why), and basically treat it like a bug report.  Asking
us to compare to behaviors that aren’t related to PostgreSQL version is
hit-or-miss.  On that note, what is the version or versions of the psql
client involved here?

Since psql is a CLI not mentioning which terminal and/or shells are in use,
or OS, is a major omission here.

David J.

---

From: "David G. Johnston" <[email-masked]>
Date: Fri, 21 Nov 2025 13:17:35 -0600

On Friday, November 21, 2025, David G. Johnston <[email-masked]>
wrote:
>
> Since psql is a CLI not mentioning which terminal and/or shells are in
> use, or OS, is a major omission here.
>

Ok, I found the versioning info.  My bad.

David J.

---

From: Ron Johnson <[email-masked]>
Date: Fri, 21 Nov 2025 14:19:01 -0500

On Fri, Nov 21, 2025 at 2:15 PM David G. Johnston <
[email-masked]> wrote:

>> The _but_ here is - obviously - that between that 1 box VS 2 other
>> boxes, there must be a difference(s) somewhere... but ! where?
>>
>

http://www.catb.org/~esr/faqs/smart-questions.html used to be the go-to
link, and should be again.

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!