Re: Get back the number of columns of a result-set prior to JSON aggregation

2023-11-28 Thread Erik Wienhold
On 2023-11-28 13:12 +0100, Dominique Devienne wrote: > Hi. I've got a nice little POC using PostgreSQL to implement a REST API > server. > This uses json_agg(t) to generate the JSON of tables (or subqueries in > general), > which means I always get back a single row (and column, before I added the

Re: Get back the number of columns of a result-set prior to JSON aggregation

2023-11-28 Thread hector vass
I think you are just trying to get the number of columns in the underlying table, no real cost to read the metadata select count(id), (select count(attrelid) from pg_attribute where attrelid= 't1'::regclass and attnum>0) , json_agg(t) from t1 t; select count(id), (select count(attrelid) from

Get back the number of columns of a result-set prior to JSON aggregation

2023-11-28 Thread Dominique Devienne
Hi. I've got a nice little POC using PostgreSQL to implement a REST API server. This uses json_agg(t) to generate the JSON of tables (or subqueries in general), which means I always get back a single row (and column, before I added the count(t.*)). But I'd like to get statistics on the number of