How do you optimize the request for the number of values in the columns of the table by hundreds of millions?
-
How can I optimize the request to obtain the number of values in the table columns?
My request now looks like this:
SELECT count('col1'), [...] count('col25') FROM scheme.table
Is he right, is he in any way optimized or rewritten differently?
The problem is, it's supposed to be in the table with which I work 158 million lines, and I'm afraid it's gonna be done just before I die.
-
Maybe you can. approximate statistics that can be found https://www.postgresql.org/docs/12/view-pg-stats.html :
select * from pg_stats where schemaname='<your_schema_name>' and tablename='<your_table_name>'
It may be possible to establish indices for non-small columns and compare the compliance plan with and without indices. But to do so carefully - sometimes the creation of an index can hurt. This is particularly relevant for the tables that are often written, since postgreSQL will have to update the indices.
The PS can certainly be remarked. https://swarm64.com/post/postgresql-columnstore-index-intro/ but according to the commentaries, you have no right of admin.