From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jorge Daniel <elgaita@hotmail.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Docker + postgreSQL : OOM killing in a large Group by operation
Date: Thu, 05 Apr 2018 13:27:07 -0400
Message-ID: <14878.1522949227@sss.pgh.pa.us> (raw)
In-Reply-To: <SC1P15201MB2461D3920C38C6C0FA8AE0ADBCBB0@SC1P15201MB2461.LAMP152.PROD.OUTLOOK.COM>
References: <SC1P15201MB2461D3920C38C6C0FA8AE0ADBCBB0@SC1P15201MB2461.LAMP152.PROD.OUTLOOK.COM>
Jorge Daniel <elgaita@hotmail.com> writes:
> I have a problem with a query that grabs a bunch of rows and then does an aggreate operation, at that moment it gots killed by OOM-killer, I don't know why, the engine starts using tmpfiles as expected , and then tries to work in memory and gots killed.
> SELECT count(*)
> FROM "changelog_change_transaction"
> INNER JOIN "changelog_change_stats" ON ( changelog_change_stats.changelog_change_transactionid = changelog_change_transaction.changelog_change_transactionid )
> LEFT OUTER JOIN "changelog_change_group" ON ( changelog_change_transaction.changelog_change_groupid = changelog_change_group.changelog_change_groupid )
> WHERE ( changelog_change_group.companyid = 40 OR changelog_change_group.companyid = 1 OR changelog_change_group.companyid = 53 OR changelog_change_group.companyid IS NULL )
> AND changelog_change_transaction.started_at > '2017-04-21'
> GROUP BY "changelog_change_transaction"."changelog_change_transactionid", "changelog_change_transaction"."epoch", "changelog_change_transaction"
> ."changelog_change_groupid", "changelog_change_transaction"."started_at", "changelog_change_transaction"."duration_microseconds", "changelog_change_transaction"."changed_items", "changelog_change_transaction"."xmin"
> ;
Why are you grouping on xmin?
> For sure if the GROUP BY the one that causes this OOM (when I removed it, the query finish ok ) , so I've change the query-plan to avoid the HashAggregate:
> But the explain still shows:
That's because type XID doesn't have sort support, only hash support,
so hash aggregation is the only way to do the query at all.
regards, tom lane
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: tgl@sss.pgh.pa.us, elgaita@hotmail.com
Subject: Re: Docker + postgreSQL : OOM killing in a large Group by operation
In-Reply-To: <14878.1522949227@sss.pgh.pa.us>
References: <SC1P15201MB2461D3920C38C6C0FA8AE0ADBCBB0@SC1P15201MB2461.LAMP152.PROD.OUTLOOK.COM> <14878.1522949227@sss.pgh.pa.us>
* 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