From: | Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Query plan not using index for some reason. |
Date: | 2002-10-01 17:40:13 |
Message-ID: | 3D99DDFD.1030703@mega-bucks.co.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
>
>>$ psql TMP -c "explain select products.id as pid from
>>products,rel_genres_movies where maker_id='53' OR
>>(rel_genres_movies.minor_id='11' AND rel_genres_movies.prod_id=products.id)"
>
>
> Is that *really* the query you want to run?
>
> Rows having maker_id=53 will be joined to *every* row of the other
> table. I'm suspecting you really wanted
> where (maker_id='53' OR rel_genres_movies.minor_id='11') AND
> rel_genres_movies.prod_id=products.id
> so that the join behaves sensibly.
As you can see my SQL ability is poor ... you are of course absolutely
right ...
Which query would be most efficient, the one you gave or
select id from products where maker_id='53' UNION select prod_id from
rel_genres_movies where minor_id='11'
I think they are both equivalent but I am wondering which is most
efficient ...
Jc
From | Date | Subject | |
---|---|---|---|
Next Message | Roland Roberts | 2002-10-01 17:43:02 | Re: [GENERAL] arrays |
Previous Message | Tom Lane | 2002-10-01 17:13:45 | Re: Query plan not using index for some reason. |