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.98.2) (envelope-from ) id 1xDjOj-00000000ftJ-1Eib for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 14:10:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xDjOi-0000000AsxJ-1A2z for pgsql-general@arkaria.postgresql.org; Mon, 05 Oct 2026 14:10:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xDjOh-0000000AswP-3jwy for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 14:10:31 +0000 Received: from mail-ej2-x10.google.com ([2a00:1450:4864:34::10]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xDjOf-00000000UGd-3GQO for pgsql-general@lists.postgresql.org; Mon, 05 Oct 2026 14:10:30 +0000 Received: by mail-ej2-x10.google.com with SMTP id a640c23a62f3a-c29703cb470so313641466b.0 for ; Mon, 05 Oct 2026 07:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1791209428; x=1791814228; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=f6jGlfnqqUTtqrz6gJuTTgcDEbgvqEwfkbGwmw+qjDM=; b=NJ4Na3ipugNlwIDKK9vPHDFD/2VbRFfwCRf9CdhulkjwVxNud0Wp7DVQZlsAb1BWqW KDWrDC+dXhEEiXtKc5jPduSTLIuBGOU67cIEjAJiWiBKWgOTQck2mcZ1PCcchQmHNHo6 zdbK/LhFzHM4Pg9UVAQJ7gKi5H2RVtEuzHTwsB8ejN1jOCktYpuETDN5G5MFNF9smG1A o+sLtmoIlM9ml05e14bFKofX4R8uET4pOGUKEFZU8ddOWJ9cy6vJTJW4zBzJWLhnvLb4 1nEDbaeRBkqOIx5sXihIo4O+onUWz6JmD1qZ//OxpUJDFEx7vhx6DJXW/E9w2cyz9AwX vvqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791209428; x=1791814228; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=f6jGlfnqqUTtqrz6gJuTTgcDEbgvqEwfkbGwmw+qjDM=; b=Obg+qbFOD43cQ3MVo1g8Vl2lzQfhLmMF9IARpH5BMn0utJmunceqYZSzgzOGtVlvqK jw0MiHGmMH6SpvTiLLqZ0lcCNUKvG2y9t8U+BFQ8RTG8aXDO3c9ZK+fKsv57jEFDHj+Z S+p9im8xt8xVHUfns/tYs7KV69IsXsF9H5c2scOJdQwc2NBgv1/5jigWRPwxjiYS9lPH xGWg5C2iLR13RRNYPaTyQLSWYVel4Z2cqg06N/3vpB0Xs5hndjIaiF5kfCUz4DzjmLaD qMGG08w+smn2Aj1n2vkWJ4zoc4wsyZrTV+dJHqovZ1Ui6bJ6cVJL4T/Q9Cl3iIFjAKFG 8elw== X-Gm-Message-State: AFq9FYI1t0HRCs0HKrhRcQ8fb9Z8+kVfjGs3BQ7fLeocbUCarN0j1ma4 6PAm0uOcQJhMrYHefqfk0EcEp5LpAomONYTGl29DadbBQTrVACGEunoa4rSGdA82N3atCsZkS8f EIEu6XE4= X-Gm-Gg: AYBFou037CoSSMgX9GYZSPLXM9l2XqYk7fVsDLmbOhZvJCqDmmYuTTisbuFsqs/zpNt cGa6nHFa0XbQD5Z3Muf/NFdGrSKxzKNIog2VE4WWzIPfKnOLNMSqqWS7eV4byAj4FFpy7QtzQ1+ R+ypem2vHs2e/Z/RDKovRk3qYm6/n05tybDmLer/rcgx0R8ytjPc3QPis2Xxn1aE1IoJEuOEpk+ nQtg7prjr5S5DUspQNbMekOdDgqlPotUpkozE6MRAhpGd+68vNynY7N4odVkmUwPEovHETPdwST /ngCybnMzktcQNGGXN7lTmisNOpjh2zOLb3vTbQb1N7nDpgD6USMDcpndT9CD9hT4j3Y2IZJ8bF KnOjHye8uVm22JNp8+dhSOALROC7hLewRNHOvLXHMlg5ys8hB1xllqRL6Oe31aB6zwngtHXjoX5 W4lcLOnXaUKbAO7jvnJ7Auzl5rh7NMxW/5DzGbrNHpDIEYCPJwaGur39HlWZpmETDVXwQzMpB2Z yG1+ooozti6THDxLM9htBGchoo= X-Received: by 2002:a17:907:d90:b0:c26:3107:71bb with SMTP id a640c23a62f3a-c2e4ada6f07mr1025751266b.24.1791209428289; Mon, 05 Oct 2026 07:10:28 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:8b5b:c776:83dc:e5e8:cfc]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c3157829106sm76178966b.12.2026.10.05.07.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Oct 2026 07:10:27 -0700 (PDT) Message-ID: <1f2d35acc290d5644cac1217048745ff156e4af0.camel@cybertec.at> Subject: Re: Parsing of hex encoding strings From: Laurenz Albe To: Thomas de Zeeuw Cc: pgsql-general@lists.postgresql.org Date: Mon, 05 Oct 2026 16:10:26 +0200 In-Reply-To: References: <088bd47f443ee4b8f657e3dbfadf611a560aa95d.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 2026-10-05 at 12:58 +0200, Thomas de Zeeuw wrote: > Not great that the first thing I read that this a design error, especiall= y since > you=E2=80=99re not familiar with the entire system. In any case, allow me= to expand on > why we do it this way. I could only go by what you told us, and as you said "strings", I assumed y= ou were talking about character strings, not binary data. Full-text search is no g= ood for binary data, even if encoded - it is only useful for natural language strin= gs. > We have various columns that we want to search, most of them are English = text > (or at least some kind of human language). However, one of them is a publ= ic key > encoded as a hex string. We want to search all those columns in single qu= ery > and since most of them are English text we decided on full text search. W= e > imagined one of the words in the search vector would simply be the hex en= coded > public key. This actually works pretty well for our use case, with the ex= ception > of the case I=E2=80=99ve described in the original email. >=20 > The trigram search doesn=E2=80=99t work well for the English text columns= we have. > We could do the trigram search just for the hex encoded public key, but w= e > thought it would return too many false positives given that we=E2=80=99re= only > interested in exact and prefixed matches. The similarity searching proper= ty > of trigrams would be negative here as we could include public keys that= =E2=80=99s > we're not searching for. If all you want to do is prefix matches and exact matches, I would use an ordinary LIKE with a regular B-tree index. That should work well, unless the public keys are large. In that case, you could try the ^@ operator and an SP-GiST index. Or resort to trigrams. > We=E2=80=99ll resort to converting the hex encoded public key to a vector= /query > by casting instead of using the various functions for this. No idea what a vector/query is, but good if it works for you. Yours, Laurenz Albe