"John E. Rylander" <rylander@prolexia.com> writes:
> ... I have a PL/PGSQL analytical
> function that iteratively drops a table, queries to create a new table of
> the same name based on iterated parameters, and then runs numerous queries
> on the resulting table, storing a few summary records to a log table. The
> nested loops in the function intelligently iterate tens or hundreds of
> thousands of times on tables containing tens or low-hundreds of thousands of
> records.
> The problem is, I think, since this function is involuntarily
> wrapped in a transaction, PostgreSQL wastes a TON of time and space keeping
> track of every single interim table, and eventually (pretty soon, in fact)
> it runs out of disk space.
It might be possible to teach the system that it could immediately
unlink the table file when dropping a table that was created in the
current transaction. See the NOTE in smgrscheduleunlink() for a hint
about one way to do it. I think you'd have to worry about matching
subtransaction nest levels, but if they're the same then allowing
inverse unlink requests to "blow each other up" would work.
regards, tom lane