From 42a5aa2dce1d96c4e708a7d59acf4ce85b008011 Mon Sep 17 00:00:00 2001 From: "Stephen R. van den Berg" <srb@cuci.nl> Date: Mon, 18 May 2020 15:26:32 +0200 Subject: [PATCH] pgsql: Speed up resync(). --- lib/modules/Sql.pmod/pgsql.pike | 2 +- lib/modules/Sql.pmod/pgsql_util.pmod | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/modules/Sql.pmod/pgsql.pike b/lib/modules/Sql.pmod/pgsql.pike index 28ded5c82e..79ebad3ef0 100644 --- a/lib/modules/Sql.pmod/pgsql.pike +++ b/lib/modules/Sql.pmod/pgsql.pike @@ -1167,7 +1167,7 @@ private void startquery(int forcetext, .pgsql_util.sql_result portal, string q, ERROR("Current transaction is aborted, " "commands ignored until end of transaction"); } - if (transtype != NOTRANS) + if (transtype != NOTRANS || .pgsql_util.nodataresprefix->match(q)) tp = .pgsql_util.describenodata; // Description already known else if (!forcetext && forcecache == 1 || forcecache && sizeof(q) >= MINPREPARELENGTH) { diff --git a/lib/modules/Sql.pmod/pgsql_util.pmod b/lib/modules/Sql.pmod/pgsql_util.pmod index 0cc914194a..e2effa721d 100644 --- a/lib/modules/Sql.pmod/pgsql_util.pmod +++ b/lib/modules/Sql.pmod/pgsql_util.pmod @@ -109,7 +109,7 @@ private Regexp dontcacheprefix = iregexp("^\a*(FETCH|COPY)\a"); private Regexp paralleliseprefix = iregexp("^\a*((SELEC|INSER)T|(UPDA|DELE)TE|(FETC|WIT)H)\a"); - /* Statements matching transbeginprefix will cause the driver + /* Statements matching transbeginprefix will cause the driver to * insert a sync after the statement. * Failure to do so, will result in portal synchronisation errors * in the event of an ErrorResponse. @@ -117,7 +117,7 @@ private Regexp paralleliseprefix final Regexp transbeginprefix = iregexp("^\a*(BEGIN|START)([; \t\f\r\n]|$)"); - /* Statements matching transendprefix will cause the driver + /* Statements matching transendprefix will cause the driver to * insert a sync after the statement. * Failure to do so, will result in portal synchronisation errors * in the event of an ErrorResponse. @@ -125,6 +125,13 @@ final Regexp transbeginprefix final Regexp transendprefix = iregexp("^\a*(COMMIT|ROLLBACK|END)([; \t\f\r\n]|$)"); + /* Statements matching nodataresprefix will cause the driver + * to skip asking for a query description and query results, since there + * are no arguments or results to begin with. + */ +final Regexp nodataresprefix + = iregexp("^\a*(RESET|CLOSE|DISCARD)\a"); + /* For statements matching execfetchlimit the resultrows will not be * fetched in pieces. This heuristic will be sub-optimal whenever * either an UPDATE/DELETE/INSERT statement is prefixed by WITH, or @@ -138,7 +145,7 @@ final Regexp transendprefix * tradeoff. */ private Regexp execfetchlimit - = iregexp("^\a*((UPDA|DELE)TE|INSERT" + = iregexp("^\a*((UPDA|DELE)TE|INSERT|CREATE|DROP" "|RESET|CLOSE|DISCARD)\a|\aLIMIT\a+[1-9][; \t\f\r\n]*$"); private void default_backend_runs() { // Runs as soon as the -- GitLab