From: Hartranft, Robert M. (GSFC-423.0)[RAYTHEON CO] <robert.m.hartranft@nasa.gov>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: question on hash joins
Date: Thu, 19 Oct 2017 15:48:05 +0000
Message-ID: <E46ADDFD-C631-441C-9859-7A956CFBCACE@nasa.gov> (raw)
In-Reply-To: <30523.1508422449@sss.pgh.pa.us>
References: <60286BB5-0A38-42C8-A673-5289CA6D2354@nasa.gov>
<63F14C4C-1518-4EAA-9EBE-87222988F073@nasa.gov>
<22675.1508361426@sss.pgh.pa.us>
<B4DE522C-7B7B-47DC-9143-B3087A7487D5@nasa.gov>
<30523.1508422449@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>
Thanks Tom,
Given that the hash would only contain keys and values needed for supporting
the query I am having a hard time understanding why I am exceeding the
10 GB temp_file_limit.
In my case the hash estimates 660888 rows from table1
and I verified that is accurate.
In theory, the hash only contains a bigint key, bigint value, and some overhead.
But even if I assume 50 bytes per row that gives a total size of
33,044,400 bytes for the hash which is way below the 10 GB limit.
What could be causing the temp_file growth?
select granuleid
from table2
where granuleid in (select granuleid from table1 where collectionid = 22467);
ERROR: temporary file size exceeds temp_file_limit (10485760kB)
explain select granuleid
from table2
where granuleid in (select granuleid from table1 where collectionid = 22467);
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
Hash Join (cost=597264.56..18687640.08 rows=644348762 width=8)
Hash Cond: (table2.granuleid = table1.granuleid)
-> Seq Scan on table2 (cost=0.00..10598010.62 rows=644348762 width=8)
-> Hash (cost=586509.04..586509.04 rows=655562 width=8)
-> Index Only Scan using idx_tabl1 on table1 (cost=0.57..586509.04 rows=655562 width=8)
Index Cond: (collectionid = '22467'::bigint)
(6 rows)
Bob
On 10/19/17, 10:14 AM, "Tom Lane" <tgl@sss.pgh.pa.us> wrote:
"Hartranft, Robert M. (GSFC-423.0)[RAYTHEON CO]" <robert.m.hartranft@nasa.gov> writes:
> Sorry if I am being dense, but I still have a question…
> Is it possible for me to estimate the size of the hash and a value for
> the temp_file_limit setting using information in the explain plan?
Well, it'd be (row_overhead + data_width) * number_of_rows.
Poking around in the source code, it looks like the row_overhead in
a tuplestore temp file is 10 bytes (can be more if you have nulls in
the data). Your example seemed to be storing one bigint column,
so data_width is 8 bytes. data_width can be a fairly squishy thing
to estimate if the data being passed through the join involves variable-
width columns, but the planner's number is usually an OK place to start.
> For example, one possibility is that the hash contains the entire tuple for each
> matching row.
No, it's just the columns that need to be used in or passed through the
join. If you want to be clear about this you can use EXPLAIN VERBOSE
and check what columns are emitted by the plan node just below the hash.
regards, tom lane
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
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-admin@postgresql.org
Cc: robert.m.hartranft@nasa.gov, tgl@sss.pgh.pa.us
Subject: Re: question on hash joins
In-Reply-To: <E46ADDFD-C631-441C-9859-7A956CFBCACE@nasa.gov>
References: <60286BB5-0A38-42C8-A673-5289CA6D2354@nasa.gov> <63F14C4C-1518-4EAA-9EBE-87222988F073@nasa.gov> <22675.1508361426@sss.pgh.pa.us> <B4DE522C-7B7B-47DC-9143-B3087A7487D5@nasa.gov> <30523.1508422449@sss.pgh.pa.us> <E46ADDFD-C631-441C-9859-7A956CFBCACE@nasa.gov>
* 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