Re: Slow update with simple query

Поиск
Список
Период
Сортировка
От Arnaud Lesauvage
Тема Re: Slow update with simple query
Дата
Msg-id 45801A1B.6070200@freesurf.fr
обсуждение исходный текст
Ответ на Re: Slow update with simple query  (Ragnar <gnari@hive.is>)
Ответы Re: Slow update with simple query
Re: Slow update with simple query
Список pgsql-performance
Ragnar a écrit :
> On mið, 2006-12-13 at 14:38 +0100, Arnaud Lesauvage wrote:
>> Jens Schipkowski a écrit :
>> > On Wed, 13 Dec 2006 13:23:41 +0100, Arnaud Lesauvage <thewild@freesurf.fr>
>> >> Why is this query better than the other one ? Because it runs the
>> >> "(field IN ('some','other') AND field2 = 'Y')" once and then executes
>> >> the join with the resulting set ?
>> > True. The Subselect in FROM clause will be executed once and will be
>> > joined using the condition at where clause. So your condition at t2 is not
>> > executed for each row in t1(2mio records) but for each row in t2(1k
>> > records). And the boolean value is already set during update.
>>
>> OK Jens, thanks for clarifying this.
>> I thought the planner could guess what to do in such cases.
>
> don't worry, it will.
> this is not your problem

Indeed, the new query does not perform that well :

"Hash Join  (cost=112.75..307504.97 rows=2024869 width=355) (actual time=53.995..246443.811 rows=2020061 loops=1)"
"  Hash Cond: ("outer".uid = "inner".uid)"
"  ->  Seq Scan on t1 (cost=0.00..261792.01 rows=2033001 width=338) (actual time=19.342..234304.499 rows=2033001
loops=1)"
"  ->  Hash  (cost=110.20..110.20 rows=1020 width=53) (actual time=4.853..4.853 rows=1020 loops=1)"
"        ->  Seq Scan on t2  (cost=0.00..110.20 rows=1020 width=53) (actual time=0.017..2.586 rows=1020 loops=1)"
"Total runtime: 2777844.892 ms"

I removed all unnecessary indexes on t1 before running the query (I left the index on uid and the multicolumn index
containindthe updated field). 
I believe the multicolumn-functional-index computation is taking some time here, isn't it ?

Regards
--
Arnaud

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

Предыдущее
От: Ragnar
Дата:
Сообщение: Re: Slow update with simple query
Следующее
От: Cosimo Streppone
Дата:
Сообщение: Re: New to PostgreSQL, performance considerations