Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHB6G-0004Du-Oi for pgsql-general@arkaria.postgresql.org; Fri, 20 Aug 2021 20:26:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mHB6F-00042b-Pd for pgsql-general@arkaria.postgresql.org; Fri, 20 Aug 2021 20:26:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mHB6F-00042S-3w for pgsql-general@lists.postgresql.org; Fri, 20 Aug 2021 20:26:47 +0000 Received: from mail-pg1-x535.google.com ([2607:f8b0:4864:20::535]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mHB68-0000yM-8c for pgsql-general@lists.postgresql.org; Fri, 20 Aug 2021 20:26:45 +0000 Received: by mail-pg1-x535.google.com with SMTP id k24so10328423pgh.8 for ; Fri, 20 Aug 2021 13:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=z6+aPl3K6iWbkDaFcn9PGr9qcqX0C3CgqTBSSWUgT4s=; b=QknhZyGbiqiEKyYfBamOqAbCLi7JKayInF2fTg9kNy9c56tHnfDIfTcXBF4iMo9q9c eiTpaMrzTI+lJe6Jrd3Ap+uW2OomhFjJqNFQUnFQBX+e/Pg/JURL4Jj5iVkFV/PbNh/3 dDSHCeMmivILdIw2IGEwsmyiifkCp8/+C9OhjWj0pylEoRmUGK5N2yp0AY09xcfLVxJS 2Ws8WliLXhDOYGvy7BoyZEVgRX9LhNebzXVOxersRxzCUR2LA1h9a0NJYFvTb+G3jFDE eFCVEeDDMkmU+GDsNp9rLg14UhKtPVm7Gia2hGNS65Rwo08wu5Khq7ldA2Llpi44OBqS s9vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=z6+aPl3K6iWbkDaFcn9PGr9qcqX0C3CgqTBSSWUgT4s=; b=oYTLnEMKNu7ZxFYk1TF+7rFaBYRM3tsL3+V3e5dDo7OQptvVzWSgL0J9YUGxr1fF0P lQjr7Mq+t3ktWZ41JUpE/y5mW5I/2K7JPf6QMLnj21HVAL1zLGyOC7wz2wJx1SfOLnGp mktqxLSTlHT+EJrxZEib9kkc0VrKaLnPJqC/znTyYCv7QPExSyoztk6Ganr6GZYXd853 /RB89yArrJs+hRzXjX/30SzgoQ6nb73kSklwjQRT09m4VeBJtwp8aTpxyDwzQjhcRyjR P4KhkT5faoZEOb8NJNcjxupYEDWEdpG7dOHC4e/yK6+8l78G4sXW/PqR52Sd+Ia3rdQ4 W1Hg== X-Gm-Message-State: AOAM531lzWvt5JSNOBOwJ72xA+7LpNanRvsdF7e1ii05wNSXCyRbiyTc vLV/ovh8g0HaDPWQcCD0OruSD5rJm+KPFjKXwycVOf2lKGHHkW5sGBqLjIxrwmUQGrA+cK4t1aD rL21mrEhuq7q4My/Xak2ssvq9jFc3sdjGdxlUntpHmn8Iwu39OnaGyjhBzrcxMfYSeBY3MQDmd0 Ka9V4qhaXy8Z/8UVc20bb+dtTMjdvRjZ7NdDQXcCXjoopMsKXeXmfb X-Google-Smtp-Source: ABdhPJzJUA9wtUPrOS0nfDSg7Ybvcj0c4otAmJ7wtXTVrMYZMvtkvXO/cULCjZ2jl6bvUYGWALp7KA== X-Received: by 2002:a65:6642:: with SMTP id z2mr8216019pgv.240.1629491198915; Fri, 20 Aug 2021 13:26:38 -0700 (PDT) Received: from laptop280-ma-us.hitronhub.home (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id g14sm7883670pfr.31.2021.08.20.13.26.38 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Aug 2021 13:26:38 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: [E] Regexp_replace bug / does not terminate on long strings From: Mark Dilger In-Reply-To: Date: Fri, 20 Aug 2021 13:26:37 -0700 Cc: pgsql-general Content-Transfer-Encoding: quoted-printable Message-Id: <060D9E3A-C827-4EDD-AFB7-C70EF5DCD186@enterprisedb.com> References: <1809528.1629412955@sss.pgh.pa.us> <1917678.1629478364@sss.pgh.pa.us> To: Miles Elam X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Aug 20, 2021, at 12:51 PM, Miles Elam = wrote: >=20 > Unbounded ranges seem like a problem. Seems so. The problem appears to be in regcomp.c's repeat() function = which handles {1,SOME} differently than {1,INF} > Seems worth trying a range from 1 to N where you play around with N to = find your optimum performance/functionality tradeoff. {1,20} is like '+' = but clamps at 20. For any such value (5, 20, whatever) there can always be a string with = more repeated words than the number you've chosen, and the call to = regexp_replace won't do what you want. There is also an upper bound at = work, because values above 255 will draw a regex compilation error. So = it seems worth a bit of work to determine why the regex engine has bad = performance in these cases. It sounds like the OP will be working around this problem by refactoring = to call regexp_replace multiple times until all repeats are eradicated, = but I don't think such workarounds should be necessary. =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company