From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | bhirt(at)mobygames(dot)com |
Cc: | pgsql-hackers(at)postgresql(dot)org, Brian Hirt <bhirt(at)loopy(dot)berkhirt(dot)com> |
Subject: | Re: pg_attribute growing and growing and growing |
Date: | 2000-08-19 05:22:43 |
Message-ID: | 22194.966662563@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Brian Hirt <bhirt(at)mobygames(dot)com> writes:
> I run a site that get's a fair amount of traffic and we use temporary
> table extensively for some more complex queries (because by breaking
> down the queries into steps, we can get better performance than by
> letting postgres plan the query poorly) I assume that creating a
> temporary table and then dropping it will cause the pg_attribute table
> to grow because our pg_attribute grows by about 15MB per day and if it
> isn't vacuumed nightly the system slows down very quickly. After
> "vacuum analyze pg_attribute", the pg_attribute table is back to it's
> normal small size. However, the two indexes on pg_attribute do not
> shrink at all.
Indexes in general are not shrunk by vacuum. The only clean solution
I see for this is to convert vacuum to do the "drop/rebuild index"
business internally --- but AFAICS we can't do that safely without some
sort of file versioning solution. See past threads in pghackers.
Possibly a better short-term attack is to eliminate the need for so
many temp tables. What's your gripe about bad planning, exactly?
Another possibility, which just screams HACK but might fix your problem,
is to swap the order of the columns in the two indexes on pg_attribute:
foo=# \d pg_attribute_relid_attnam_index
Index "pg_attribute_relid_attnam_index"
Attribute | Type
-----------+------
attrelid | oid
attname | name
unique btree
foo=# \d pg_attribute_relid_attnum_index
Index "pg_attribute_relid_attnum_index"
Attribute | Type
-----------+----------
attrelid | oid
attnum | smallint
unique btree
Since table OIDs keep increasing, this formulation ensures that new
entries will always sort to the end of the index, and so space freed
internally in the indexes can never get re-used. Swapping the column
order may eliminate that problem --- but I'm not sure what if any
speed penalty would be incurred. Thoughts anyone?
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-08-19 05:39:04 | Re: configure CXX bug |
Previous Message | Tom Lane | 2000-08-19 05:03:01 | Re: Large # of Tables, Getting ready for the enterprise |