From: Semler Miloslav <Miloslav.Semler@crytur.cz>
To: Cory Tucker <cory.tucker@gmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Query Using Massive Temp Space
Date: Mon, 20 Nov 2017 08:12:04 +0000
Message-ID: <d43bbfdb9926422b9954abf8cc795483@crytur.cz> (raw)
In-Reply-To: <CAG_=8kBoWY4AXwW=Cj44xe13VZnYohV9Yr-_hvZdx2xpiipr9w@mail.gmail.com>
References: <CAG_=8kBoWY4AXwW=Cj44xe13VZnYohV9Yr-_hvZdx2xpiipr9w@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>
Hello,
I have one question… Why you using so huge amount of grouping columns? Is there some reason for it? It is not definitelly fast method. I would prefer firstly do named query grouped by ids (account_id, candidate_id, parent_id) and then left join table candidates (to get rest of requested columns) out of this named query on this ids if it is possible.
You also avoid of hash indexing of these nine columns so you will save certain ammount of memory.
Miloslav
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Cory Tucker
Sent: Monday, November 20, 2017 7:17 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Query Using Massive Temp Space
Hello,
I have a query that is using a tremendous amount of temp disk space given the overall size of the dataset. I'd love for someone to try to explain what PG is doing and why its using so much space for the query.
First off, the system is PG 9.6 on Ubuntu with 4 cores and 28 GB of RAM. The query in question is a fairly large join of several tables (6) including some aggregations. The overall dataset size of the 6 tables in question is about 20GB and the largest table is about 15M rows. The query is essentially a dump of most of the data from these tables joined together to be used in another system.
When the query runs it begins to use an aggressive amount of temp space on the volume over the course of many hours, until it reaches about 95% capacity and then tapers off. Never completes though. The temp space it uses is around 1.5TB out of a 2TB volume. Again, the total size of the relations in question is only 20GB.
Can anyone explain how the query could possibly use so much temp space?
Query and query plan are attached. Please let me know if any more info is needed.
thanks
--Cory
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: Miloslav.Semler@crytur.cz, cory.tucker@gmail.com
Subject: Re: Query Using Massive Temp Space
In-Reply-To: <d43bbfdb9926422b9954abf8cc795483@crytur.cz>
References: <CAG_=8kBoWY4AXwW=Cj44xe13VZnYohV9Yr-_hvZdx2xpiipr9w@mail.gmail.com> <d43bbfdb9926422b9954abf8cc795483@crytur.cz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox