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 1qHTZS-000686-Bm for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Jul 2023 18:19:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qHTZR-0005ot-1o for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Jul 2023 18:19:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qHTZQ-0005ok-Lb for pgsql-hackers@lists.postgresql.org; Thu, 06 Jul 2023 18:19:12 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qHTZO-002aaS-0h for pgsql-hackers@lists.postgresql.org; Thu, 06 Jul 2023 18:19:12 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-313e09a5b19so2000776f8f.0 for ; Thu, 06 Jul 2023 11:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20221208.gappssmtp.com; s=20221208; t=1688667549; x=1691259549; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=Ar5pLyXsPgLa7w9gs9TV9nEtUmoOXEestLiLFsWPIFQ=; b=WCkmEn/jT3Ch2I7ALTBxhnZktDVvq+ZBBEtVLZP8L5jbgPja+Xe73bvDhhwKngM2iN e78gihNmlonjUTi3JCCfnIoKEvjDN2AwP47eIN3PK+VTj2bVZ7PjKlSq1s/LbGcvaqe/ qJ7X2yWgoMPAlgUHLFK83Ur4KxDPzF+2Jv30QqkfdrLKdf5BtATfFRRMnO9Q1jBJ+yxj 5ftYox++Fa4fG6aMJpJzXNkJB6wRMp81vrM+FDFh7JzKwC414u2d4kOVuriwrfdWDmIn z6eOAmPwj9xCHT9GUxOIR2OcIClGf8eV4ZycKut9fDZdsksIkN6MJWU5OYrjOQoAEELc rv8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688667549; x=1691259549; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Ar5pLyXsPgLa7w9gs9TV9nEtUmoOXEestLiLFsWPIFQ=; b=QwdDOM+5/iObnqTpce4L+nTqZcYzmG0bXgMARLF0/tmMIAW9zmJKzsuvlZyPvN7Fjx f/HR5WmGyW9P8AhQI99KVuMaF/0ADC9l6/dll6FFqnU/oRi4cLIgTlpNq+GgTGF7ahN1 7epYxwaNhLJtYMel+r93tyCNFKaqGAPIU6+o5oOUNoWE3d6+3I5V8fVomG/7QcvXpHwM 4QMSPRkDy++/ywbtHaisxx+hvwSySRVuIwddDBFcGv5gpFqwLG2vzeOx2naXw0TFHf5e 8K9HQraks++jFd4yRD1ZFjychIJzsNaKQ591DVnUfDf28jv/z77FuDTRuJYp1tMBGjNd R/aw== X-Gm-Message-State: ABy/qLZUocDjjqlL0q0iiFzpzqQ0rDow/lKhOfK6lAgOdCAit1916z+f PlNyJsle2NxNxVvVx9Qzo+ACCpu2495nC5v9da8= X-Google-Smtp-Source: APBJJlHnLGiz59fNlFbOWh2eF65lHJPedhLzEaG+LR2LdowWgNYne85hD6dkeygKnnVkIyJWqYPxCQ== X-Received: by 2002:a5d:6dca:0:b0:314:d00:7352 with SMTP id d10-20020a5d6dca000000b003140d007352mr2631293wrz.32.1688667548950; Thu, 06 Jul 2023 11:19:08 -0700 (PDT) Received: from localhost.localdomain (62-46-248-159.adsl.highway.telekom.at. [62.46.248.159]) by smtp.gmail.com with ESMTPSA id g3-20020a5d5543000000b0030e5bd253aasm2450894wrw.39.2023.07.06.11.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jul 2023 11:19:08 -0700 (PDT) Message-ID: Subject: Re: [PATCH] Add support function for containment operators From: Laurenz Albe To: Kim Johan Andersson , pgsql-hackers@lists.postgresql.org Date: Thu, 06 Jul 2023 20:19:07 +0200 In-Reply-To: <4e6efd382b3195eb7ea438b7219cc94d9399c0bd.camel@cybertec.at> References: <94f64d1f-b8c0-b0c5-98bc-0793a34e0851@kimmet.dk> <4e6efd382b3195eb7ea438b7219cc94d9399c0bd.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.4 (3.46.4-1.fc37) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sat, 2023-04-29 at 17:07 +0200, Kim Johan Andersson wrote: > > I had noticed that performance wasn't great when using the @> or <@=20 > > operators when examining if an element is contained in a range. > > Based on the discussion in [1] I would like to suggest the following= =20 > > changes: > >=20 > > This patch attempts to improve the row estimation, as well as opening= =20 > > the possibility of using a btree index scan when using the containment= =20 > > operators. I managed to break the patch: CREATE DATABASE czech ICU_LOCALE "cs-CZ" LOCALE "cs_CZ.utf8" TEMPLATE templ= ate0; \c czech CREATE TYPE textrange AS RANGE (SUBTYPE =3D text, SUBTYPE_OPCLASS =3D text_= pattern_ops); CREATE TABLE tx (t text); INSERT INTO tx VALUES ('a'), ('c'), ('d'), ('ch'); EXPLAIN SELECT * FROM tx WHERE t <@ textrange('a', 'd'); QUERY PLAN =20 =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2= =95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95= =90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90=E2=95=90= =E2=95=90=E2=95=90 Seq Scan on tx (cost=3D0.00..30.40 rows=3D7 width=3D32) Filter: ((t >=3D 'a'::text) AND (t < 'd'::text)) (2 rows) SELECT * FROM tx WHERE t <@ textrange('a', 'd'); ERROR: could not determine which collation to use for string comparison HINT: Use the COLLATE clause to set the collation explicitly. The replacement operators are wrong; it should be ~>=3D~ and ~<~ . Also, there should be no error message. The result should be 'a', 'c' and 'ch'. Yours, Laurenz Albe