Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jC9qk-0001V4-0P for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 22:29:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jC9qi-0005WY-Rd for pgsql-general@arkaria.postgresql.org; Wed, 11 Mar 2020 22:29:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jC9qi-0005WJ-HY for pgsql-general@lists.postgresql.org; Wed, 11 Mar 2020 22:29:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jC9qb-00083F-PY for pgsql-general@lists.postgresql.org; Wed, 11 Mar 2020 22:29:12 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 02BMT0w6005285; Wed, 11 Mar 2020 18:29:00 -0400 From: Tom Lane To: David Rowley cc: Sterpu Victor , pgsql-general@lists.postgresql.org Subject: Re: Query to retrieve the index columns when a function is used. In-reply-to: References: Comments: In-reply-to David Rowley message dated "Thu, 12 Mar 2020 10:09:47 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <5283.1583965740.1@sss.pgh.pa.us> Date: Wed, 11 Mar 2020 18:29:00 -0400 Message-ID: <5284.1583965740@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk David Rowley writes: > On Tue, 10 Mar 2020 at 02:16, Sterpu Victor wrote: >> How can I retrieve this detail? > Those details are in the indexprs column. There's an item there for > each 0 valued indkey. It's not going to be particularly easy for you > to parse that from SQL. Internally in PostgreSQL, we have functions > that could give you that information easily, but to access those from > SQL you'd need to write something in C. You could use pg_get_indexdef(). I agree that parsing indexprs from SQL is not to be recommended --- aside from being very complex, it would break on a regular basis, because we change those structs often. regards, tom lane