Re: pg_attribute growing and growing and growing

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_attribute growing and growing and growing
Дата
Msg-id 22194.966662563@sss.pgh.pa.us
обсуждение исходный текст
Ответ на pg_attribute growing and growing and growing  (Brian Hirt <bhirt@mobygames.com>)
Список pgsql-hackers
Brian Hirt <bhirt@mobygames.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  | oidattname   | name
unique btree

foo=# \d pg_attribute_relid_attnum_index
Index "pg_attribute_relid_attnum_index"Attribute |   Type
-----------+----------attrelid  | oidattnum    | 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


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Large # of Tables, Getting ready for the enterprise
Следующее
От: Tom Lane
Дата:
Сообщение: Re: configure CXX bug