Re: join optimization problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: toby(at)lyricist(dot)com(dot)au
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: join optimization problem
Date: 2003-08-03 16:19:49
Message-ID: 27076.1059927589@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Toby Tremayne <toby(at)lyricist(dot)com(dot)au> writes:
> The output of explain analyze is this:

> -> Nested Loop (cost=0.00..1657643.30 rows=65807 width=568)
> (actual time=539.82..543404.25 rows=1537 loops=1)
> Join Filter: ("inner".thread_id =
> ("outer".thread_id)::double precision)

Hm. It would appear that you've been inconsistent about the datatype of
thread_id. Current PG releases are not capable of using anything smarter
than a nested-loop join when there is a forced datatype coercion
involved in the join condition. Try making your column datatypes the
same.

Also, do you really need a LEFT JOIN, or would plain inner join do?
It's hard for me to imagine a zero-message thread. If you do have such
things, do you care whether this query finds them? (I'm not sure that
eliminating the LEFT would really help any, but it couldn't hurt, since
LEFT restricts the planner's choices.)

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message evl 2003-08-04 08:17:56 How to check: is some key referenced from sometable
Previous Message Rod Taylor 2003-08-03 13:04:11 Re: join optimization problem