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 1uhzlj-006Q8f-6g for pgsql-general@arkaria.postgresql.org; Sat, 02 Aug 2025 00:06:35 +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 1uhzlg-00A7ay-HW for pgsql-general@arkaria.postgresql.org; Sat, 02 Aug 2025 00:06:32 +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 1uhzlg-00A7aq-4S for pgsql-general@lists.postgresql.org; Sat, 02 Aug 2025 00:06:32 +0000 Received: from mail-yw1-x112b.google.com ([2607:f8b0:4864:20::112b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uhzld-000I8L-0o for pgsql-general@lists.postgresql.org; Sat, 02 Aug 2025 00:06:31 +0000 Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-71b6ab52e8cso16032497b3.0 for ; Fri, 01 Aug 2025 17:06:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754093187; x=1754697987; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=w2H/hufmVndsPwTYKJ5hEzrpj/aZ0nPjsnvc1wTIeBg=; b=JRVWFTE+EYT6DbZquK//00VJXuiOpYHs+9o5j8es2cVjPhRj/61R6YmRJuk3CsjFE3 BMRHICy9TOOTM7Z8VRyfoWVFM1HhjYzoFlKR32rXacDuZlUfdp4hXPAw7qJV4OxUXIko yIGW09BVAwlBFJm9UQ7voVqz9wdq0h/O6YIKKPK2c24FJFLXlk93HUtsjYVsS0y0aIwL 7rIUbNOiv7o0wikBrcTOJDzFL4dktPirbikPbnAHiRhVXnXezD5ucEkQqow+jMZJZjy4 xM/9Nigf3VpGFmUYT0Q5ScyhMUqWD1sy3rppw3CYwLSWHkWtbNp82Xl9ElnoOvSzzMNT w3WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754093187; x=1754697987; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w2H/hufmVndsPwTYKJ5hEzrpj/aZ0nPjsnvc1wTIeBg=; b=WwvDcvvHUWLz0ZRsblMDCE0VddBlBX2Sf2RN3ZpO81HQK5yZYfvFjwiDZ1Zj8h4T6j xbPzEBCIimzOBQ11lEsVTPnWXh4Ic97TY+JM/MLq1zuABzT0XPX8mjtoNqLl8lcJ57Qo 0aUDtwMZRPVdIADyQWAJ7uohsPD/mv7i28uF/yN7bmn/pu1NgNKQAgKOwK5SLE2fRkNB wDeLh0fUA7Jdz2v8Bb0OYNcVJzm+4lzaevnH0Cgva6Ocldko4ZJm5hCUQ1HNQuKTHQmU sHs/ONECpyTwf2nQ9LfWo/k4u4ru0u7kjEhr2Y621prU6v+iCZrC2+wZaVufFwHLpGaS y6eA== X-Forwarded-Encrypted: i=1; AJvYcCXYEa13TNzz2aNRjfC8N57snWAe1I9Stz3BngNmhOSz94LyFRfMUTCiCUALbYCaowtePH7res5DYYiMdjkn@lists.postgresql.org X-Gm-Message-State: AOJu0YxvN0dwIwGiaAk3hp+BDlaag7RE+b4c6dbUfciawVog7XDLvUnn 4puTXpmC0GytkWhR9yEuIrcDhPa+0PbcS3sMs6HsJMp08OpAN+rgkAIdGBEr2GC1AlrWpFq0rY/ uc/WoIv68JKV3W1d1OqsfHzHrQ+GX+ew= X-Gm-Gg: ASbGncvvY2I2AHpwrMyoV4d0yq6iyGgKe/boSpkwDEar8qSpwV2WJYkFvBpdnrFn9CP 69JF+OEH3BGSZZkO8wQ+7NgGsd+/Z5RklFS7gElagtAGBw4AaYmhCniz34Fmx7xZx8oel6SulsY 9zz2FWiZYM0Bx3PpbWn+Y1Lyx/M1A5VTlyIvYa86R2z0kcfJ1Su3FLCxfuJ65mkJIkFghA2pu6C /+g0eHYH2u9EGPV3SEQ6g== X-Google-Smtp-Source: AGHT+IEVwDKSfgHybb3GbGmjeetaqxoU1IQPZhl4giRYC1Uhl+Eitgm2SAEIt61KTa+QQYWQ4ULSI344ll0Aq/O46+4= X-Received: by 2002:a05:690c:60c7:b0:70e:2d3d:ace6 with SMTP id 00721157ae682-71b7ed743f7mr22991857b3.15.1754093187363; Fri, 01 Aug 2025 17:06:27 -0700 (PDT) MIME-Version: 1.0 References: <090d8588-e74e-4436-8f69-05ce8624379b@aklaver.com> <0BC8BEBF-3B1F-4E69-A1B9-CCCDF9617168@thebuild.com> <7281c379994ffc70cebb68423f5b8ba339d0d75f.camel@cybertec.at> <2fad4427bff83bc73f9b4215e284a76343f046f2.camel@cybertec.at> In-Reply-To: <2fad4427bff83bc73f9b4215e284a76343f046f2.camel@cybertec.at> From: Igor Korot Date: Fri, 1 Aug 2025 19:06:13 -0500 X-Gm-Features: Ac12FXyromJsv_WAUnD2pcO93JXLfbW1Hk4Tbo748J5oECvYIJcorL8zh1Tii1I Message-ID: Subject: Re: Get info about the index To: Laurenz Albe Cc: David Barbour , Jon Zeppieri , Christophe Pettus , Adrian Klaver , "pgsql-generallists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Laurenz, On Tue, Jul 29, 2025 at 7:07=E2=80=AFAM Laurenz Albe wrote: > > On Tue, 2025-07-29 at 06:46 -0500, Igor Korot wrote: > > SELECT > > t.relname AS table_name, > > i.relname AS index_name, > > a.attname AS column_name > > FROM > > pg_class t, > > pg_class i, > > pg_index ix, > > pg_attribute a > > WHERE > > t.oid =3D ix.indrelid AND > > i.oid =3D ix.indexrelid AND > > a.attrelid =3D t.oid AND > > a.attnum =3D ANY(ix.indkey) AND > > t.relkind =3D 'r' AND -- 'r' for regular table > > t.relname =3D 'your_table_name' -- Optional: filter by table name > > ORDER BY > > t.relname, > > i.relname, > > a.attnum; > > > > I can build on top of this query, however I have 2 issues: > > > > First and most important one - they are filtering by just table name. > > How can I filter by the fully qualified name - catalog.schema.table? > > "catalog" is irrelevant, since PostgreSQL doesn't allow cross-database qu= eries. > > To add a filter for the schema, use > > AND t.relnamespace =3D 'schemaname'::regnamespace > > > Second - how cn I get the partial index condition? Either the whole > > WHERE clause (which I will have to parse) > > or the broken down one (field, condition {AND|OR} field, condition}? > > SELECT pg_get_expr(ix.indpred, t.oid) I'm looking at the pg_index table and I see it has: [quote] indisexclusion bool If true, this index supports an exclusion constraint [/quote] If I read the docs correctly, this field indicates whether the WHERE condition is actually present. Am I right? Thank you. > > Yours, > Laurenz Albe