Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tYDI7-005xRw-Dh for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 23:59:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tYDI5-001snI-3j for pgsql-performance@arkaria.postgresql.org; Wed, 15 Jan 2025 23:59:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tYDI4-001sn9-Mw for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 23:59:17 +0000 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tYDI2-000dmg-2f for pgsql-performance@lists.postgresql.org; Wed, 15 Jan 2025 23:59:16 +0000 Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5d3cf094768so581988a12.0 for ; Wed, 15 Jan 2025 15:59:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jp-hosting.net; s=google; t=1736985554; x=1737590354; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=9Xk9YASZ/sErsa0K8EOsuT+lZkU2hxdWY89RgJJry28=; b=I3gu7jb+rmVOHlCi2iZ5FW0r2UlHJ2TUwGNH6M1XH9H10eM1kWUdoB3gd2a10MSQUu g8MIrTM29eM9gN0wtNkI0V/l0MLN6vWNrONB8foOf2V8/K5h/kLdt1aWRa/p51+aLi/Q AZxjbYoUCxMIppFETrdtrgRj8ZIUqKuVAhZbLj7GzhC5/QTpZvdrSkwpuBse/6tRtq1Y cQFJy57aK/T9uEBk+5kOKnpepnVrmN5bFMIHu/ROTwx5NPrmsNmDHO34YVsvWHvzGj2m ikLoDV2hyCV7IGx09EeEdYTN0SUKAU2Yd3QQcccqHzpeHiNYfz5gSsGmtimjvg1MSKRm F2wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736985554; x=1737590354; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Xk9YASZ/sErsa0K8EOsuT+lZkU2hxdWY89RgJJry28=; b=SGFZdfhLP3cSLEeEWyEYEhtmhTaSqicg9fdntyQtxCx0kiuCMDfK/QiR8rvAk1twZu C1BUPg2QxBOZcHOOq0KkMSaUWh3WK/XgyiTLq/HDbMM30NAh1Ooy6Gyb0AvT5FMkwYsH sfAuuVsIGfEu/G5jXdXrjYEwJfM8sYpf5RbhfzAmtrSMLUvxe+bW66vp2FJzho9O/VP3 TOdgE1ND84FzTn598ieUX7QACcxYWidCL+p659mfIiiYi9IePenvXMcwEOQMgvyXQA9Z LKWyk9BGxmNjVR1ofdrWaiv5e9f56O+wOfl0tZC7upQfDpAXMVm37eeSgGP1HlIKmFDV zbWw== X-Gm-Message-State: AOJu0YyOCrV1f0qC9DpwT4xKkcNs89hQiXzURAAsUzod+afidcLL7ewZ 2nO8+VjZS3hlQ1WhBF7YLpKiK9pUC055k+BA95XPvK/VsBKI/htyvnEiNjCzL9IPzNWr3e2FzZT QzPnJl9gE0hOBeTbeRFhMD5qx0BPATG6l0mQR X-Gm-Gg: ASbGncvGjAvBiH0A7RBhSmtDgpDlO/yacgnKVwIEJivxIl/kmEqt33eO4iEkhJJL5Vp n6GxTble10b0wMHqHBLcn/ugSptNHL9vc9ntcrw== X-Google-Smtp-Source: AGHT+IHX1JhfbRd3dIit84vOUirVGrAaOyXll/0OdUl48+Ro/o1higGCu4oBWkJ71WjtqEciotY4/nnXI2m1tM7ddn8= X-Received: by 2002:a05:6402:278a:b0:5d4:5e4:1561 with SMTP id 4fb4d7f45d1cf-5d972e178ecmr28627458a12.20.1736985553493; Wed, 15 Jan 2025 15:59:13 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: James Addison Date: Wed, 15 Jan 2025 23:58:59 +0000 X-Gm-Features: AbW1kvYzTYIshW4zbxsfom1S1g0rQVJrgWryodnqLKT9P-iwZyouZjjzvNi3NTE Message-ID: Subject: Re: Question: consolidating strpos searches? To: Greg Sabino Mullane Cc: pgsql-performance@lists.postgresql.org, Tom Lane Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 4 Jan 2025 at 19:04, Greg Sabino Mullane wrote= : > > On Sat, Jan 4, 2025 at 12:16=E2=80=AFPM James Addison wrote: >> >> In the context of considering writing a patch: would the complexity of i= mplementing such a feature for PostgreSQL be worth the potential >> performance benefits? > > Probably not. As Tom said, this sounds like it should be tried as an exte= nsion. Will do; thanks, both of you. >> And either way, is there more I should learn about and consider? How wo= uld I provide convincing supporting >> evidence if I do write a patch? > > As this is the performance mailing list, it might help to describe the re= al-world problem being encountered here. There are other ways to solve this= particular issue. Among them would be using OR not AND in your contrived e= xample, using partial indexes, using pg_trgm, using regular expressions ( = i.e. WHERE value ~ '(known|suffix)' ), redesigning your table and/or querie= s, and outsourcing the searching of large strings to a system more suitable= for it. The example is indeed contrived, and the idea doesn't resolve a problem I've encountered -- in fact, my interest stems from an open TODO item to implement Boyer-Moore string search. I began considering how to implement multiple string pattern search in that context -- but LIKE/ILIKE introduce a few non-trivial considerations -- notably wildcard patterns -- compared to strpos. Whether to require strict ordering of search results can also be relevant, depending on the pattern match approach (and boolean operators, as noted) involved.