<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Ishii San<br><br>Can you have a look at the attached patch which tries to extract some performance in the area of query parsing and query analysis for routing decisions. Most of the performance gains from the changes in the patch can be observed in large data INSERT statements.<br><br>Patch contains the following changes</div><div dir="ltr">==========<br>1-- The idea here is since Pgpool-II only needs a very little information about the queries especially for the insert queries to decide where it needs to send the query,</div><div dir="ltr">for example: For the INSERT queries we only need the type of query and the relation name.</div><div dir="ltr">But since the parser we use in Pgpool-II is taken from PostgreSQL source which parses the complete query including the value lists ( which is not required by Pgpool).</div><div dir="ltr">This parsing of value part seems very harmless in small statements but in case of INSERTs with lots of column values and large data in each value item, this becomes significant.</div><div dir="ltr">So this patch adds a smaller bison grammar rule to short circuit the INSERT statement parsing when it gets the enough information required for Pgpool-II.<br><br>2-- The patch also re-arranges some of the if statements in pool_where_to_send() function and tries to make sure the pattern_compare and pool_has_function_call calls should only be made when they are absolutely necessary.<br><br>3--Another thing this patch does is, it tries to save the raw_parser() calls in case of un-recognised queries. Instead of invoking the parser of &quot;dummy read&quot; and &quot;dummy write&quot; queries in case of syntax error in original query, the patch adds the functions to get pre-built parse_trees for these dummy queries.<br><br>4-- strlen() call is removed from scanner_init() function and is passed in as an argument to it, and the reason is we already have the query length in most cases before invoking the parser so why waste CPU cycles on it. Again this becomes significant in case of large query strings.<br><br>Finally the patch tries to remove the unnecessary calls of pool_is_likely_select()<br><br>As mentioned above the area of improvements in this patch are mostly around writing queries and for the testing purpose I used a INSERT query with large binary insert data and I am getting a very huge performance gains with this patch</div><div><br></div><div dir="ltr"><b style="font-family:monospace,monospace">Current Master Branch</b><br></div><div dir="ltr"><div><font face="monospace, monospace">================</font></div><div><div><font face="monospace, monospace">usama=# \i sample.sql </font></div><div><font face="monospace, monospace"> id  </font></div><div><font face="monospace, monospace">-----</font></div><div><font face="monospace, monospace"> 104</font></div><div><font face="monospace, monospace">(1 row)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">INSERT 0 1</font></div><div><font face="monospace, monospace">Time: <b>2059.807</b> ms (00:02.060)</font></div></div><div><br></div><div><div dir="ltr"><font face="monospace, monospace"><b>WITH PATCH</b></font></div><div dir="ltr"><font face="monospace, monospace">===============<br></font><div><div><font face="monospace, monospace">usama=# \i sample.sql </font></div><div><font face="monospace, monospace"> id  </font></div><div><font face="monospace, monospace">-----</font></div><div><font face="monospace, monospace"> 102</font></div><div><font face="monospace, monospace">(1 row)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">INSERT 0 1</font></div><div><font face="monospace, monospace">Time: <b>314.237</b> ms</font></div></div><div><font face="monospace, monospace"><br></font></div><br class="gmail-Apple-interchange-newline"></div></div><font size="4">Performance gain<b> 655.50 %</b></font><div><br></div><div><br></div><div>Comments and suggestions?</div><div><br></div><div>Please let me know if you also want the test data I used for the INSERT test</div><div><br></div><div>Thanks</div><div>Best regards</div><div>Muhammad Usama</div><div><br><div><br></div></div></div></div></div></div></div>