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 1t0ud1-00Dm2z-P2 for pgsql-docs@arkaria.postgresql.org; Wed, 16 Oct 2024 03:23:15 +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 1t0ud0-00ErTA-0q for pgsql-docs@arkaria.postgresql.org; Wed, 16 Oct 2024 03:23:14 +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.94.2) (envelope-from ) id 1t0ucz-00ErSw-Ph for pgsql-docs@lists.postgresql.org; Wed, 16 Oct 2024 03:23:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0ucx-0016jh-BT for pgsql-docs@postgresql.org; Wed, 16 Oct 2024 03:23:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49G3N8Qj4169602; Tue, 15 Oct 2024 23:23:08 -0400 From: Tom Lane To: Steve Lau cc: "pgsql-docs@postgresql.org" Subject: Re: Index of expression over table row or column In-reply-to: <964FED20-AC2E-47C5-86FB-95C356A68B81@outlook.com> References: <964FED20-AC2E-47C5-86FB-95C356A68B81@outlook.com> Comments: In-reply-to Steve Lau message dated "Wed, 16 Oct 2024 03:07:15 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <4169600.1729048988.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 15 Oct 2024 23:23:08 -0400 Message-ID: <4169601.1729048988@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Steve Lau writes: > I am reading this documentation[1], and it has a sentence that I don=E2=80= =99t quite understand: "The index columns (key values) can be either simpl= e columns of the underlying table or expressions over the table rows.=E2=80= =9D, I am thinking that for the index of expressions, aren=E2=80=99t those= expressions over table column? e.g., =E2=80=9CCREATE INDEX idx_lower_last= _name ON users(LOWER(last_name))=E2=80=9D, =E2=80=9Clast_name" is a column= rather than a row. Consider CREATE INDEX idx_lower_name ON users(LOWER(last_name || ' ' || first_name)= ); regards, tom lane