Re: Weird query plan

Поиск
Список
Период
Сортировка
От Dmitry Tkach
Тема Re: Weird query plan
Дата
Msg-id 3F68B6EB.7060708@openratings.com
обсуждение исходный текст
Ответ на Re: Weird query plan  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Weird query plan  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
Hmmm...
Indeed. I tried it in 7.2.4 on a couple of empty tables, and it does do
the right thing...
Also, I have another copy (not exact copy, but identical schema, and
similar content... but about twice smaller) of the original database...
I tried my query on it, and it works right too.
So, there must be something wrong with that particular database I suppose...

Any ideas what I should look at?

Thanks a lot!

Dima

Tom Lane wrote:

>Dmitry Tkach <dmitry@openratings.com> writes:
>
>
>>The query plan looks identical in both cases:
>>
>>
>
>
>
>>Limit  (cost=0.00..12.51 rows=1 width=8)
>>  ->  Nested Loop  (cost=0.00..1009772807.91 rows=80740598 width=8)
>>        ->  Index Scan using b_pkey on b  (cost=0.00..375410773.29
>>rows=80740598 width=4)
>>        ->  Index Scan using a_pkey on a  (cost=0.00..6.85 rows=1 width=4)
>>
>>
>
>
>
>>... which makes me think that it decides to use  b as the outer table
>>for both cases (which would obviously make it suck in the first one)... :-(
>>
>>
>
>That's what it says, all right, which seems odd to me.  Are you sure you
>looked at the right plans?
>
>
>
>>This happens on 7.2.4... I have a 7.3 database with the same schema, but
>>it is not populated with data, so I could not test it on 7.3...
>>
>>
>
>I could not reproduce a problem on 7.2.4.  I get (using toy tables, and
>suppressing the planner's urge to use mergejoin instead)
>
>lo=# explain select * from a, b where a.id >=  7901288 and a.id=b.id limit 1;
>NOTICE:  QUERY PLAN:
>
>Limit  (cost=0.00..4.97 rows=1 width=8)
>  ->  Nested Loop  (cost=0.00..1657.34 rows=333 width=8)
>        ->  Index Scan using a_pkey on a  (cost=0.00..45.50 rows=333 width=4)
>        ->  Index Scan using b_pkey on b  (cost=0.00..4.82 rows=1 width=4)
>
>EXPLAIN
>lo=# explain select * from a, b where b.id >=  7901288 and a.id=b.id limit 1;
>NOTICE:  QUERY PLAN:
>
>Limit  (cost=0.00..4.97 rows=1 width=8)
>  ->  Nested Loop  (cost=0.00..1657.34 rows=333 width=8)
>        ->  Index Scan using b_pkey on b  (cost=0.00..45.50 rows=333 width=4)
>        ->  Index Scan using a_pkey on a  (cost=0.00..4.82 rows=1 width=4)
>
>EXPLAIN
>
>which looks like the right thing.
>
>            regards, tom lane
>
>



В списке pgsql-general по дате отправления:

Предыдущее
От: Network Administrator
Дата:
Сообщение: Re: Database Recovery Procedures
Следующее
От: info@casestudio.com (Vaclav Frolik)
Дата:
Сообщение: Re: Visual database structure browser for postgresql?