postgresql/src/backend
Tom Lane 0c3405cf11 Improve performance of regular expression back-references.
In some cases, at the time that we're doing an NFA-based precheck
of whether a backref subexpression can match at a particular place
in the string, we already know which substring the referenced
subexpression matched.  If so, we might as well forget about the NFA
and just compare the substring; this is faster and it gives an exact
rather than approximate answer.

In general, this optimization can help while we are prechecking within
the second child expression of a concat node, while the capture was
within the first child expression; then the substring was saved during
cdissect() of the first child and will be available to NFA checks done
while cdissect() recurses into the second child.  It can help quite a
lot if the tree looks like

              concat
             /      \
      capture        concat
                    /      \
     expensive stuff        backref

as we will be able to avoid recursively dissecting the "expensive
stuff" before discovering that the backref isn't satisfied with a
particular midpoint that the lower concat node is testing.  This
doesn't help if the concat tree is left-deep, as the capture node
won't get set soon enough (and it's hard to fix that without changing
the engine's match behavior).  Fortunately, right-deep concat trees
are the common case.

Patch by me, reviewed by Joel Jacobson

Discussion: https://postgr.es/m/661609.1614560029@sss.pgh.pa.us
2021-03-02 11:55:12 -05:00
..
access Add TID Range Scans to support efficient scanning ranges of TIDs 2021-02-27 22:59:36 +13:00
bootstrap Update copyright for 2021 2021-01-02 13:06:25 -05:00
catalog Enhanced cycle mark values 2021-02-27 08:13:24 +01:00
commands Simplify code to switch pg_class.relrowsecurity in tablecmds.c 2021-03-02 12:30:21 +09:00
executor Add TID Range Scans to support efficient scanning ranges of TIDs 2021-02-27 22:59:36 +13:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
lib Update copyright for 2021 2021-01-02 13:06:25 -05:00
libpq Introduce symbolic names for FeBeWaitSet positions. 2021-03-01 16:10:16 +13:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Add missing TidRangeScan readfunc 2021-02-27 23:21:21 +13:00
optimizer Add TID Range Scans to support efficient scanning ranges of TIDs 2021-02-27 22:59:36 +13:00
parser Enhanced cycle mark values 2021-02-27 08:13:24 +01:00
partitioning Message style fix 2021-02-24 07:00:49 +01:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
postmaster Use SIGURG rather than SIGUSR1 for latches. 2021-03-01 12:44:12 +13:00
regex Improve performance of regular expression back-references. 2021-03-02 11:55:12 -05:00
replication Avoid repeated decoding of prepared transactions after a restart. 2021-03-01 09:11:18 +05:30
rewrite Revert "Propagate CTE property flags when copying a CTE list into a rule." 2021-02-07 12:54:08 -05:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Update copyright for 2021 2021-01-02 13:06:25 -05:00
storage Remove obsolete comment for WaitForProcSignalBarrier(). 2021-03-02 09:30:57 +13:00
tcop Use errmsg_internal for debug messages 2021-02-17 11:33:25 +01:00
tsearch Fix parsing of complex morphs to tsquery 2021-01-31 20:14:29 +03:00
utils Improve reporting for syntax errors in multi-line JSON data. 2021-03-01 16:44:17 -05:00
.gitignore
common.mk
Makefile Update copyright for 2021 2021-01-02 13:06:25 -05:00
nls.mk