Re: Feature request (or at least discussion): enable autovaccum ontemp tables - Mailing list pgsql-general

From Michael Lewis
Subject Re: Feature request (or at least discussion): enable autovaccum ontemp tables
Date
Msg-id CAHOFxGpTna8yf3bHivKNuWYYd2M2YqibWUHbX4NLnhm2u1HzmQ@mail.gmail.com
Whole thread Raw
In response to Re: Feature request (or at least discussion): enable autovaccum ontemp tables  (Ivan Voras <ivoras@gmail.com>)
List 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 );

pgsql-general by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Feature request (or at least discussion): enable autovaccum ontemp tables
Next
From: Michael Lewis
Date:
Subject: Re: json on child table or not