Re: stuck on values in 8.2

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Tom Allison <tom(at)tacocat(dot)net>
Cc: General PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: stuck on values in 8.2
Date: 2007-05-12 16:06:57
Message-ID: 934915.83815.qm@web31811.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


--- Tom Allison <tom(at)tacocat(dot)net> wrote:

> This is getting really ugly...
> it won't finish in less than .. minutes.
>
> spam=> explain select u2.token_idx, t.token_idx, foo.token from
> tokens t left outer join user_token u1 using (token_idx),
> users u left outer join user_token u2 using (user_idx),
> (values('one'),('want'),('examine'),('three')) as foo(token)
> left outer join tokens using (token)
> where u.user_idx = 15;

It looks to me that your query has (3) left joins and (3) implied cross-joins. Perhaps reforming
your query to eliminate the cross-joins with help performance. In regard to your tables <tokens>
and <user_tokens>, in this query you are referring to (2) separate instances of these tables when
a single instance these tables would probably work just fine. i.e.

tokens t vs. tokens,
user_token u1 vs user_token u2

Regards,
Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jasbinder Singh Bali 2007-05-12 16:49:46 Re: Database transaction related
Previous Message Aleksander Kmetec 2007-05-12 15:46:36 Partitioning on IS NULL / IS NOT NULL not supported?