pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Douglas Thomson <dougt@mugc.cc.monash.edu.au>
To: tgl@sss.pgh.pa.us
Cc: dougt@mugc.cc.monash.edu.au
Cc: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Back end memory consumption (was Front end memory consumption in SELECT)
Date: Fri, 3 Dec 1999 16:51:16 +1100 (EST)
Message-ID: <199912030551.QAA09331@mugca.cc.monash.edu.au> (raw)
In-Reply-To: <29989.944190601@sss.pgh.pa.us>

Tom Lane <tgl@sss.pgh.pa.us> writes:
> Douglas Thomson <dougt@mugc.cc.monash.edu.au> writes:
> > If I hadn't checked that I have indexes on
> > all the attributes (and attribute combinations) that make up the keys
> > needed for the join, I would think the back end was trying to read in
> > and sort a large part of the data just for the query!
>
> Well, of course it *is* ... the trick is to make sure that anything
> really large ends up on disk (in a temp file) and not in memory.

What I don't understand is, why would it bother trying to read in
lots of data and sort it when it already has an index sorted in the
required order? I was trying to set up the individual table indexes
so that the join could be done efficiently, and not need either lots
of memory or temporary disk files. Do indexes not get used for joins?

> Offhand the plan looks pretty reasonable for a 9-way join.  I see that
> you have two sorts and five hashes going on here.  Each of those will
> feel entitled to use as much memory as whatever your -S setting is,
> which IIRC is 512K by default.  But 3.5meg altogether isn't enough to
> explain your memory usage ... unless you are using a larger-than-normal
> -S switch?

No, I use the default.

> Also, while the sorts are pretty certain to honor your -S limit (plus or
> minus some slop), the hashes are much more probabilistic affairs.  If a
> table is much larger than the planner guesses, or if the distribution of
> tuple values is very uneven, a hash join might use a lot more memory
> than -S.  It's hard to tell whether this might be happening without a
> lot more info than EXPLAIN provides, however.  EXPLAIN shows that your
> tables being hashed are all pretty small, the largest being
> 't24 users' at 6955 rows.  If that's accurate then I doubt hash overrun
> is the explanation...

6955 rows is accurate for that table. Values could well be highly
skewed though. The joining attribute for t24 is a student ID "number"
text field, and the numbers will be grouped.

Doug.



view thread (5+ messages)

Message-ID: <199912030551.QAA09331@mugca.cc.monash.edu.au>
Permalink:  ../199912030551.QAA09331@mugca.cc.monash.edu.au/
Also on:    postgresql.org/message-id/199912030551.QAA09331@mugca.cc.monash.edu.au

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: dougt@mugc.cc.monash.edu.au, tgl@sss.pgh.pa.us
  Subject: Re: [INTERFACES] Back end memory consumption (was Front end memory consumption in SELECT)
  In-Reply-To: <199912030551.QAA09331@mugca.cc.monash.edu.au>

* 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