Re: Query runs on 9.2, but not on 9.4

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Query runs on 9.2, but not on 9.4
Дата
Msg-id 9874.1438784275@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Query runs on 9.2, but not on 9.4  (John Scalia <jayknowsunix@gmail.com>)
Список pgsql-admin
John Scalia <jayknowsunix@gmail.com> writes:
> I've got a query I use to show the amount of shared buffers in use that is
> giving me some issues. It uses the pg_buffercache extension. The query is:

> SELECT
> c.relname,
> pg_size_pretty(count(*) * 8192) as buffered,
> round(100.0 * count(*) /
> (SELECT setting FROM pg_settings
> WHERE name='shared_buffers')::integer,1)
> AS buffers_percent,
> round(100.0 * count(*) * 8192 /
> pg_relation_size(c.oid),1)
> AS percent_of_relation
> FROM pg_class c
> INNER JOIN pg_buffercache b
> ON b.relfilenode = c.relfilenode
> INNER JOIN pg_database d
> ON (b.reldatabase = d.oid AND d.datname = current_database())
> GROUP BY c.oid,c.relname
> ORDER BY 3 DESC
> LIMIT 25;

> On a 9.2 system, it runs fine and produces a list of the top 25 tables
> using the shared buffer, but on 9.3 and above, it throw a "division by
> zero" error.

It seems likely that you have at least one table in the 9.4 system for
which pg_relation_size() produces 0, but on the 9.2 system that table is
not there or is not physically zero-length.

            regards, tom lane


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

Предыдущее
От: Vasilis Ventirozos
Дата:
Сообщение: Re: Query runs on 9.2, but not on 9.4
Следующее
От: John Scalia
Дата:
Сообщение: Re: Query runs on 9.2, but not on 9.4