Re: Techniques to Avoid Temp Files

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'Duane Murphy *EXTERN*'" <duane(dot)murphy(at)gmail(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Techniques to Avoid Temp Files
Date: 2015-06-19 08:17:13
Message-ID: A737B7A37273E048B164557ADEF4A58B50F66249@ntex2010a.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Duane Murphy wrote:
> We are trying to improve performance by avoiding the temp file creation.
>
> LOG: temporary file: path "base/pgsql_tmp/pgsql_tmp8068.125071", size 58988604
> STATEMENT: SELECT iiid.installed_item__id, item_detail.id, item_detail.model_id, item_detail.type
> FROM installed_item__item_detail AS iiid
> INNER JOIN item_detail ON iiid.item_detail__id = item_detail.id
> INNER JOIN item ON (item.installed_item__id = iiid.installed_item__id )
> INNER JOIN model ON (item.id = model.item__id AND model.id = $1)

> What are the causes of temp file creation?

Operations like hash and sort that need more space than work_mem promises.

> What additional information can I gather in order have a better understanding of how to improve this
> query?

It woul be really useful to see the result of "EXPLAIN (ANALYZE, BUFFERS) SELECT ..."
for your query.

But essentially the answer to avoid temporary files is always "increase work_mem".

Yours,
Laurenz Albe

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Ian Pushee 2015-06-19 14:34:01 Slow query (planner insisting on using 'external merge' sort type)
Previous Message Sheena, Prabhjot 2015-06-18 20:26:25 Re: [PERFORM] PGBOUNCER ISSUE PLEASE HELP(Slowing down the site)