OS: Linux pi 6.6.31+rpt-rpi-v6 #1 Raspbian 1:6.6.31-1+rpt1 (2024-05-29) armv6l GNU/Linux
I can try to make a test case, essentially a large table, then "select count(*)" from table. The select works for smaller tables.
I'm using the build of postgresql packaged with the OS version above; from the apt repository and installed with "apt install postgresql". repository -
deb [ arch=armhf ] http://raspbian.raspberrypi.com/raspbian/ bookworm main contrib non-free rpi
postgres --version
postgres (PostgreSQL) 15.8 (Raspbian 15.8-0+deb12u1)