From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com>, Hans Spaans <pgsql-admin(at)lists(dot)hansspaans(dot)nl>, pgsql-admin(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: concat_ws |
Date: | 2003-08-03 23:53:57 |
Message-ID: | 4313.1059954837@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin pgsql-hackers |
I said:
> There is some code in the function inliner to abandon inlining if an
> input expression is "too expensive", but its notion of "too expensive"
> is currently just "contains subselects". I'm going to see if it helps
> to reject inlining when the input grows "too large", for some value of
> "too large".
Okay, after further study, I see that the real problem here is that when
expanding nested concat_ws calls, the expansions of the lower-level
calls would get substituted in more than one place in the outer
functions. Specifically, since $2 occurs twice in the bottom-level
function, you'd end up with an expanded tree of O(2^n) nodes for n
levels of function call.
I added code to inline_function to stop inlining if a parameter
expression to be substituted multiple times has cost greater than
10*cpu_operator_cost (which roughly means that it contains more than
10 operators or functions). This seems to cut off the problem nicely,
at least for this example. The factor of 10 is a bit of a magic number
but it seems reasonable.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2003-08-04 01:37:52 | Re: concat_ws |
Previous Message | Tom Lane | 2003-08-03 23:27:13 | Re: [HACKERS] concat_ws |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2003-08-04 00:22:51 | pgindent |
Previous Message | Bruce Momjian | 2003-08-03 23:30:26 | Release changes |