pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: negora <negora@negora.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-performance@postgresql.org <pgsql-performance@postgresql.org>
Subject: Re: Internal operations when the planner makes a	 hash join.
Date: Tue, 23 Feb 2010 23:52:56 +0100
Message-ID: <4B845C48.2030904@negora.com> (raw)
In-Reply-To: <4B83F811020000250002F579@gw.wicourts.gov>
References: <4B83E8C5.2050902@negora.com>
	<4B83A03E020000250002F4FD@gw.wicourts.gov>
	<4B8404CC.4060607@negora.com>
	<20100223165339.GF3672@alvh.no-ip.org>
	<0B256120-1CC5-4B5F-B257-CCF72DE9DE2F@richrelevance.com>
	<4B8449A4.3090109@negora.com>
	<4B83F811020000250002F579@gw.wicourts.gov>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=US-ASCII" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Verdana">Hello Kevin. I'm going to take and apply your
advices, certainly. No more "crazy" PL/PgSQLs then. I was worried
because of the possibility that repetition of fields caused some kind
of memory saturation. But I guess that PostgreSQL takes care of that
fact properly. I even might return the entire result to my external
Java application (I was using a similar approach on it too). I just
hope that the speed of that single SQL compensates the transfer of such
a big mass of data between PostgreSQL and Java in terms of delay.
Thanks ;) .<br>
<br>
<br>
</font><br>
Kevin Grittner wrote:
<blockquote cite="mid:4B83F811020000250002F579@gw.wicourts.gov"
 type="cite">
  <pre wrap="">negora <a class="moz-txt-link-rfc2396E" href="mailto:negora@negora.com">&lt;negora@negora.com&gt;</a> wrote:
 
  </pre>
  <blockquote type="cite">
    <pre wrap="">The origin of my doubt resides in the fact that I need to do a
joint between 3 HUGE tables (millions of registries) and do
certain operations with the retrieved information. I was deciding
whether to use one SELECT with 3 JOINs, as I've been doing since
the beginning, or build a PL/PgSQL function based on 3 nested "FOR
... IN SELECT ... LOOP" structures which tried to minimize the
subsequent table searches storing intermediate useful data in
arrays
    </pre>
  </blockquote>
  <pre wrap=""><!----> 
It's almost always faster (and less error prone) to write one SELECT
statement declaring what you want than to try to do better by
navigating individual rows procedurally.  I would *strongly*
recommend you write it with the JOINs and then post here if you have
any concerns about the performance.  In general, try to *declare*
what you want, and let the PostgreSQL planner sort out the best way
to navigate the tables to produce what you want.  If you hit some
particular weakness in the planner, you many need to coerce it, but
certainly you should not *start* with that.
 
-Kevin

  </pre>
</blockquote>
</body>
</html>



view thread (11+ messages)  latest in thread

Message-ID: <4B845C48.2030904@negora.com>
Permalink:  ../4B845C48.2030904@negora.com/
Also on:    postgresql.org/message-id/4B845C48.2030904@negora.com

 · 

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-performance@postgresql.org
  Cc: negora@negora.com, Kevin.Grittner@wicourts.gov
  Subject: Re: Internal operations when the planner makes a	 hash join.
  In-Reply-To: <4B845C48.2030904@negora.com>

* 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