Re: postgres table statistics

Поиск
Список
Период
Сортировка
От Ron Johnson
Тема Re: postgres table statistics
Дата
Msg-id CANzqJaAcCDZX3L1O9Dj3ETZ4JZRyX6S1JJ_EMp8NaDgCovkbbw@mail.gmail.com
обсуждение исходный текст
Ответ на postgres table statistics  (Chandy G <vgchandru@yahoo.com>)
Список pgsql-general
On Wed, Jun 12, 2024 at 3:48 AM Chandy G <vgchandru@yahoo.com> wrote:
Hi,
  We have postgres 13.9 running with tables thats got billions of records of varying sizes. Eventhough pg jdbc driver  provides a way to set fetch size to tune the driver to achieve better throughput, the JVM fails at the driver level when records of large size (say 200mb each) flows through.  this forces to reduce the fetch size (if were to operate at a fixed Xmx setting of client jvm).

It get a bit trickier when 100s of such tables exists with varying records sizes. trying to see if the fetch size can be set dynamically based on the row count and the record size distribution for a table. Unfortunately, trying to get this data by a query run against each table (for row size: max(length(t::text))) seem to be  quite time consuming too.
 
Maybe create your own table with three columns:
table_name (PK; taken from pg_class.relname)
average_rec_size (taken from sum(pg_stat.avg_width))
max_rec_size (calculated yourself)

Periodically refresh it.  (How periodic depends on how often the average and max change substantively.)

Does postgres maintain metadata about tables for the following.
1. row count


pg_class.reltuples.  This is an estimate, so make sure your tables are regularly analyzed.
 
2. max row size.


pg_stats.avg_width
 
or is there some other pg metadata that can help get this data quicker.

TIA.
 

В списке pgsql-general по дате отправления:

Предыдущее
От: Chandy G
Дата:
Сообщение: postgres table statistics
Следующее
От: Hans Schou
Дата:
Сообщение: Oracle Linux 9 Detected RPMs with RSA/SHA1 signature