Re: Query optimization with X Y JOIN

From: J(at)Planeti(dot)Biz
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Query optimization with X Y JOIN
Date: 2006-01-26 17:13:33
Message-ID: 009a01c6229b$d67c6670$0d310d05@fatchubby
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance pgsql-sql

Yes, that helps a great deal. Thank you so much.

----- Original Message -----
From: "Richard Huxton" <dev(at)archonet(dot)com>
To: <J(at)planeti(dot)biz>
Cc: <pgsql-performance(at)postgresql(dot)org>
Sent: Thursday, January 26, 2006 11:47 AM
Subject: Re: [PERFORM] Query optimization with X Y JOIN

> J(at)Planeti(dot)Biz wrote:
>> If I want my database to go faster, due to X then I would think that the
>> issue is about performance. I wasn't aware of a paticular constraint on
>> X.
>
> You haven't asked a performance question yet though.
>
>> I have more that a rudementary understanding of what's going on here, I
>> was just hoping that someone could shed some light on the basic principal
>> of this JOIN command and its syntax. Most people I ask, don't give me
>> straight answers and what I have already read on the web is not very
>> helpful thus far.
>
> OK - firstly it's not a JOIN command. It's a SELECT query that happens to
> join (in your example) three tables together. The syntax is specified in
> the SQL reference section of the manuals, and I don't think it's different
> from the standard SQL spec here.
>
> A query that joins two or more tables (be they real base-tables, views or
> sub-query result-sets) produces the product of both. Normally you don't
> want this so you apply constraints to that join (table_a.col1 =
> table_b.col2).
>
> In some cases you want all the rows from one side of a join, whether or
> not you get a match on the other side of the join. This is called an outer
> join and results in NULLs for all the columns on the "outside" of the
> join. A left-join returns all rows from the table on the left of the join,
> a right-join from the table on the right of it.
>
> When planning a join, the planner will try to estimate how many matches it
> will see on each side, taking into account any extra constraints (you
> might want only some of the rows in table_a anyway). It then decides
> whether to use any indexes on the relevant column(s).
>
> Now, if you think the planner is making a mistake we'll need to see the
> output of EXPLAIN ANALYSE for the query and will want to know that you've
> vacuumed and analysed the tables in question.
>
> Does that help at all?
> --
> Richard Huxton
> Archonet Ltd
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message vishal saberwal 2006-01-26 17:13:54 EXCEPTION Function
Previous Message Rich Shepard 2006-01-26 17:04:52 Re: Access Problem After Version Upgrade -- Update

Browse pgsql-performance by date

  From Date Subject
Next Message Jozsef Szalay 2006-01-26 17:35:25 Re: Incorrect Total runtime Reported by Explain Analyze!?
Previous Message Richard Huxton 2006-01-26 16:49:59 Re: Incorrect Total runtime Reported by Explain Analyze!?

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2006-01-26 18:02:38 Re: [HELP] Defining a function as a procedure
Previous Message Daniel Caune 2006-01-26 17:09:14 [HELP] Defining a function as a procedure