Re: Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP - Mailing list pgsql-general

From David G. Johnston
Subject Re: Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP
Date
Msg-id CAKFQuwbu-cO8kC6LhFXmuPYMH+3UNXBHNT0YHOV6L6v-RvYxdQ@mail.gmail.com
Whole thread Raw
In response to Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP  (Ryan Murphy <ryanfmurphy@gmail.com>)
Responses Re: Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP  (Ryan Murphy <ryanfmurphy@gmail.com>)
List pgsql-general
On Sunday, January 28, 2018, Ryan Murphy <ryanfmurphy@gmail.com> wrote:
Hello,

I heard at a PostgreSQL talk that you should not liberally create temp tables in the course of frequently-used functions etc, because (roughly) you're using up some of the same resources that you for your regular tables.

Is this true?  Is there an important reason not to have e.g. a plpgsql function that uses a temp table?  What are the specific problems if I do this?  Is the problem ameliorated if I add ON COMMIT DROP?

I believe the main, and maybe only, concern is the bloating of the system catalog tables since you are constantly adding and removing records.  Yes, they will be vacuumed but vacuuming and bloat on catalog tables slows every single query down to some, degree since every query has to lookup its objects is those catalogs.  Though caching probably alleviates some of that.

The way most temp tables are used on commit drop likely has little impact on this, but the specific usage pattern matters a great deal in answering the question.

David J.

pgsql-general by date:

Previous
From: Ryan Murphy
Date:
Subject: Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP
Next
From: Ryan Murphy
Date:
Subject: Re: Downsides of liberally using CREATE TEMP TABLE ... ON COMMIT DROP