Re: Subqueries or Joins? Problems with multiple table query

From: Thom Brown <thombrown(at)gmail(dot)com>
To: Stefan Schwarzer <stefan(dot)schwarzer(at)grid(dot)unep(dot)ch>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Subqueries or Joins? Problems with multiple table query
Date: 2010-02-23 13:46:16
Message-ID: bddc86151002230546n6fef7acag70e41b60503bc84d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 23 February 2010 13:43, Stefan Schwarzer
<stefan(dot)schwarzer(at)grid(dot)unep(dot)ch> wrote:
>>>> Select countries.name, basel.year, basel.value, cites.year, cites.value
>>>> From countries
>>>> Left Join basel on basel.id_country = countries.id_country and
>>>> basel.value=1
>>>> Left Join cites on cites.id_country = countries.id_country and
>>>> cites.value=1
>>>
>>> I would have thought so, but the query turns forever.
>>
>> How many rows in each of your tables, and what indexes do you have?
>
> around 5000 rows
>

It takes a long time for just 5000 rows? Could you provide the
execution plan for it by putting EXPLAIN ANALYZE at the front of your
query and post the result here?

Thom

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message A. Kretschmer 2010-02-23 14:13:17 Re: Subqueries or Joins? Problems with multiple table query
Previous Message Stefan Schwarzer 2010-02-23 13:43:07 Re: Subqueries or Joins? Problems with multiple table query