Use list_delete_xxxcell O(1) instead of list_delete_ptr O(N) in some places

Поиск
Список
Период
Сортировка
От Hou, Zhijie
Тема Use list_delete_xxxcell O(1) instead of list_delete_ptr O(N) in some places
Дата
Msg-id b3517353ec7c4f87aa560678fbb1034b@G08CNEXMBPEKD05.g08.fujitsu.local
обсуждение исходный текст
Ответы Re: Use list_delete_xxxcell O(1) instead of list_delete_ptr O(N) in some places  (Luc Vlaming <luc@swarm64.com>)
Re: Use list_delete_xxxcell O(1) instead of list_delete_ptr O(N) in some places  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
Hi

I found some code places call list_delete_ptr can be replaced by list_delete_xxxcell which can be faster.

diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index db54a6b..61ef7c8 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -1005,8 +1005,8 @@ sort_inner_and_outer(PlannerInfo *root,
         /* Make a pathkey list with this guy first */
         if (l != list_head(all_pathkeys))
             outerkeys = lcons(front_pathkey,
-                              list_delete_ptr(list_copy(all_pathkeys),
-                                              front_pathkey));
+                              list_delete_nth_cell(list_copy(all_pathkeys),
+                                                   foreach_current_index(l)));
         else
             outerkeys = all_pathkeys;    /* no work at first one... */

diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c
index fe777c3..d0f15b8 100644
--- a/src/backend/rewrite/rewriteHandler.c
+++ b/src/backend/rewrite/rewriteHandler.c
@@ -650,7 +650,7 @@ adjustJoinTreeList(Query *parsetree, bool removert, int rt_index)
             if (IsA(rtr, RangeTblRef) &&
                 rtr->rtindex == rt_index)
             {
-                newjointree = list_delete_ptr(newjointree, rtr);
+                newjointree = list_delete_cell(newjointree, l);


Best regards,
houzj



Вложения

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

Предыдущее
От: "movead.li@highgo.ca"
Дата:
Сообщение: Re: Wrong statistics for size of XLOG_SWITCH during pg_waldump.
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Possible NULL dereferencing null pointer (src/backend/executor/nodeIncrementalSort.c)