Re: Feature request (or at least discussion): enable autovaccum on temp tables

From: Michael Lewis <mlewis(at)entrata(dot)com>
To: Ivan Voras <ivoras(at)gmail(dot)com>
Cc: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Feature request (or at least discussion): enable autovaccum on temp tables
Date: 2019-05-31 17:00:57
Message-ID: CAHOFxGpTna8yf3bHivKNuWYYd2M2YqibWUHbX4NLnhm2u1HzmQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> So, a related question, since we have dozens of temp tables and a lot of
> code, is there a way to look up what temp tables are being created by the
> current session, so I can do a VACUUM or ANALYZE on all of them in bulk? I
> know I can inspect pg_temp_* schema, but how to figure out which one is
> from the current session?
>

Any table in pg_temp schema would belong to the current session.
Technically the schema has some number appended on the end, but to the
creating connection of those temp tables, it is just pg_temp. Probably you
should be analyzing the temp tables immediately after insert/update/delete,
OR just before first use. As others have said, you have no stats of most
common values or historgrams or any other info unless you analyze. If your
temp tables have many columns which are only selected and not used for
joins or ordering, then you may not need stats on those columns and could
save some cycles by specifying the columns, eg. *analyze
pg_temp.temp_table_name( join_field1, join_field2, order_by_field );*

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michael Lewis 2019-05-31 17:08:03 Re: json on child table or not
Previous Message Christopher Browne 2019-05-31 16:33:59 Re: Feature request (or at least discussion): enable autovaccum on temp tables