Re: Using temp tables with web apps (No State)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Danny Aldham <danny(at)lennon(dot)postino(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Using temp tables with web apps (No State)
Date: 2001-11-30 15:07:17
Message-ID: 7638.1007132837@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Danny Aldham <danny(at)lennon(dot)postino(dot)com> writes:
> I am wondering if anyone has a decent method of cleaning up
> these temporary tables after use.
> I am considering creating a table called Temp_Tables, and inserting the
> name of the temp_tables into it, and having a cron job read Temp_Tables
> for a list of temp_tables to drop. Any other suggestions are appreciated.

Are you able to choose the table names freely? If so, consider encoding
the needed info right into the table name:

myapp_temp_200111301003_1234

(I'm imagining the current timestamp and PID as the variable components
here, but you could alter that to suit your needs.) Then a scan of
pg_class tells the cron job what to do. This avoids the overhead of an
extra table insert/delete, and more importantly avoids any possibility of
the Temp_Tables table getting out of sync with reality.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Ewald Geschwinde 2001-11-30 16:40:36 what's this debug mean?
Previous Message Brett W. McCoy 2001-11-30 15:04:44 Re: Logging