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 1syyjY-003PIr-WF for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2024 19:22:02 +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 1syyjX-005nG6-VU for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2024 19:22:00 +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 1syyjX-005nFx-Hn for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2024 19:21:59 +0000 Received: from mout-u-204.mailbox.org ([80.241.59.204]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1syyjU-000OLh-94 for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2024 19:21:59 +0000 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4XPfl22vGdz9swc; Thu, 10 Oct 2024 21:21:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ewie.name; s=MBO0001; t=1728588110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=U/V/sTp8CenUl9VUS5nJOof08GDwBarGErFrgCbsxus=; b=nIGXuCFFO9XRJzpzySPTYcgdD7OasE+nkHbYwPY/C8/VMJZIxMcYKA5VaZAJWQZd5gtuqS jB9D7DM6XYjYlocW95CTMyIXXtN5IpIkJ20V2LFH2vHt0at35gGLrIYeuQGUf4s8g5mf52 dHhzhGfi+ilRILV5tw3elG9aXrKhVq9xbjmfwm83qTxhHsI0DMTUdwiAnZIs5bKSL28+JX 8tZ01NFT6BFirQYbiriy1uRcKCHXD07pLLQZJWEPj7bb1ztjMgVVxx0OT2MJTppeg1mMWH jm2noV5kEk3W2R4Tbo5cbFe3qIDp+F3oCwUk49XwEW6hb133m1oLSVfXqk6mrQ== Date: Thu, 10 Oct 2024 21:21:46 +0200 From: Erik Wienhold To: sud Cc: pgsql-general Subject: Re: Question on indexes Message-ID: <88e5c335-c70e-4973-9b71-6c12e251e5b7@ewie.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-10-10 20:49 +0200, sud wrote: > However, we are seeing that one of the databases has multiple hash indexes > created. So I wanted to understand from experts here, if it's advisable in > any specific scenarios over B-tre despite such downsides? Two things come to my mind: 1. Btree puts a limit on the size of indexed values, whereas hash indexes only store the 32-bit hash code. 2. Of the core index types, only btree supports unique indexes. Example of btree's size limit: CREATE TABLE b (s text); CREATE INDEX ON b USING btree (s); INSERT INTO b (s) VALUES (repeat('x', 1000000)); ERROR: index row requires 11464 bytes, maximum size is 8191 The docs have more details: https://www.postgresql.org/docs/current/btree.html https://www.postgresql.org/docs/current/hash-index.html -- Erik