Re: Temp files for simple queries

From: MichaelDBA <MichaelDBA(at)sqlexec(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: "Radoulov, Dimitre" <cichomitiko(at)gmail(dot)com>, pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: Temp files for simple queries
Date: 2021-06-22 12:00:37
Message-ID: 6fab4381-4a47-0b99-43a9-1ff1c97efd39@sqlexec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I'm wondering if bloat could be causing a problem.  Perhaps more blocks
are written to disk including a lot of blocks with little or no data due
to bloat.

Julien Rouhaud wrote on 6/22/2021 7:55 AM:
> On Tue, Jun 22, 2021 at 01:51:55PM +0200, Radoulov, Dimitre wrote:
>> Just to clarify: the size of the temp file is 7MB and with work_mem of 4MB
>> it clearly doesn't fit.
>>
>> But why an "order by" of a 440kB of data would require 7MB.
>>
>> One possible reason is that that the number of records in that table varies
>> significantly during the day,
> That would be the logical explanation. You could configure auto_explain to
> make sure of that (https://www.postgresql.org/docs/current/auto-explain.html)
>
>> but - if that's the case - I would expect that
>> the table would be much bigger than 440kB (size taken using \dt+).
> Not necessarily. autovacuum can truncate the file if all the trailing blocks
> are empty (and if it can acquire an exclusive lock fast enough), so if some
> client inserts a lot of rows, process them and remove them all, and later on
> slowly start to insert new rows you will get that behavior.
>
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Radoulov, Dimitre 2021-06-22 12:05:57 Re: Temp files for simple queries
Previous Message Julien Rouhaud 2021-06-22 11:55:06 Re: Temp files for simple queries