Re: EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема Re: EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?
Дата
Msg-id CA896D7906BF224F8A6D74A1B7E54AB301750B8E@JENMAIL01.ad.intershop.net
обсуждение исходный текст
Ответ на Re: EXECUTE 'EXECUTE ...' or how to use dynamic prepared statements ?  ("Dirk Jagdmann" <jagdmann@gmail.com>)
Список pgsql-sql
Hello Dirk,


I have to disagree.

Your first update query is very low. It probably implies to run the sub
select statement for each row to be updated.

Following update statement is already much faster: (using UPDATE FROM)
  update test_table     set mygroup= t.mygroup  from test_table as t  where t.family = test_table.family  and t.rang =
1 and table.rang=0  -- perform the updte only when required  and mygroup <> t.mygroup; 

But when you are dealing with  "parent - child" relations within a
single table as in my case,
a single table scan with SELECT DISTINCT ON  and a row by row comparison
on the result set appears to be faster.

I tested both approaches on tables with ca. 14'000'000 rows where 25% of
them needed to be updated.

The above update statement run in 5H30' where my function did the job in
2H.
(as my tables are very large, much time is lost in i/o wait)



Cheers,

Marc




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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: ISO time zone format
Следующее
От: roy simkes
Дата:
Сообщение: tsearch2 query question