Re: review: Non-recursive processing of AND/OR lists - Mailing list pgsql-hackers

From Gurjeet Singh
Subject Re: review: Non-recursive processing of AND/OR lists
Date
Msg-id CABwTF4W+nDfknBS3xfQ8jpSyTyKnJoJshKPiO33X4N9sEkNf7g@mail.gmail.com
Whole thread
In response to review: Non-recursive processing of AND/OR lists  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Thanks for the review Pavel.

On Tue, Jun 18, 2013 at 3:01 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
Hello

related to

https://commitfest.postgresql.org/action/patch_view?id=1130
http://www.postgresql.org/message-id/CABwTF4V9rsjiBWE+87pK83Mmm7ACdrG7sZ08RQ-4qYMe8jvhbw@mail.gmail.com


* motivation: remove recursive procession of AND/OR list (hangs with
10062 and more subexpressions)

* patch is short, clean and respect postgresql source code requirements
* patch was applied cleanly without warnings
* all regression tests was passed
* I successfully evaluated expression with 100000 subexpressions
* there is no significant slowdown

possible improvements

a = (A_Expr*) list_nth(pending, 0);

a = (A_Expr*) linitial(pending);

not well comment

should be -- "If the right branch is also an SAME condition, append it to the"

+                       /*
+                        * If the right branch is also an AND condition, append it to the
+                        * pending list, to be processed later. This allows us to walk even
+                        * bushy trees, not just left-deep trees.
+                        */
+                       if (IsA(a->rexpr, A_Expr) && ((A_Expr*)a->rexpr)->kind == root_kind)
+                       {
+                               pending = lappend(pending, a->rexpr);
+                       }
+                       else
+                       {
+                               expr = transformExprRecurse(pstate, a->rexpr);
+                               expr = coerce_to_boolean(pstate, expr, root_kind == AEXPR_AND ?
"AND" : "OR");
+                               exprs = lcons(expr, exprs);
+                       }

I don't see any other issues, so after fixing comments this patch is
ready for commit

Regards

Pavel Stehule



--
Gurjeet Singh

http://gurjeet.singh.im/

EnterpriseDB Inc.

pgsql-hackers by date:

Previous
From: Jeff Janes
Date:
Subject: Re: Git-master regression failure
Next
From: Alvaro Herrera
Date:
Subject: Re: Git-master regression failure