Skip site navigation (1) Skip section navigation (2)

Improving performance on system catalog

From: "Daniel Cristian Cruz" <danielcristian(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Improving performance on system catalog
Date: 2007-03-28 12:59:18
Message-ID: (view raw or flat)
Lists: pgsql-performance
Hi all.

I would like to speed up this query:

 FROM pg_stat_user_tables;

                                                               QUERY PLAN
 Subquery Scan pg_stat_all_tables  (cost=747.72..791.10 rows=195 width=236)
(actual time=11.582..13.632 rows=200 loops=1)
   ->  HashAggregate  (cost=747.72..752.10 rows=195 width=136) (actual time=
11.571..12.813 rows=200 loops=1)
         ->  Hash Join  (cost=209.32..745.28 rows=195 width=136) (actual
time=1.780..6.477 rows=453 loops=1)
               Hash Cond: ("outer".relnamespace = "inner".oid)
               ->  Hash Left Join  (cost=206.87..702.69 rows=227 width=76)
(actual time=1.729..5.392 rows=507 loops=1)
                     Hash Cond: ("outer".oid = "inner".indrelid)
                     ->  Seq Scan on pg_class c  (cost=0.00..465.22 rows=227
width=72) (actual time=0.013..2.552 rows=228 loops=1)
                           Filter: (relkind = 'r'::"char")
                     ->  Hash  (cost=205.40..205.40 rows=587 width=8)
(actual time=1.698..1.698 rows=0 loops=1)
                           ->  Seq Scan on pg_index i
(cost=0.00..205.40rows=587 width=8) (actual time=
0.004..1.182 rows=593 loops=1)
               ->  Hash  (cost=2.44..2.44 rows=6 width=68) (actual time=
0.035..0.035 rows=0 loops=1)
                     ->  Seq Scan on pg_namespace n  (cost=0.00..2.44 rows=6
width=68) (actual time=0.013..0.028 rows=6 loops=1)
                           Filter: ((nspname <> 'pg_catalog'::name) AND
(nspname <> 'pg_toast'::name))
 Total runtime: 13.844 ms

I think there would be good to create an index on pg_class.relkind and
pg_class.relnamespace, but its impossible since its a catalog table.

Any way to make it a default index (system index)?

Its an old PostgreSQL server:

SELECT version();
 PostgreSQL 7.4.13 on x86_64-redhat-linux-gnu, compiled by GCC
x86_64-redhat-linux-gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-2)

Daniel Cristian Cruz
Analista de Sistemas


pgsql-performance by date

Next:From: chris smithDate: 2007-03-28 13:24:41
Subject: Re: Improving performance on system catalog
Previous:From: davidDate: 2007-03-28 05:34:38
Subject: Re: Sunfire X4500 recommendations

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group