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 1ugj8D-006kVL-Qh for pgsql-general@arkaria.postgresql.org; Tue, 29 Jul 2025 12:08:34 +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 1ugj7E-000Wju-KG for pgsql-general@arkaria.postgresql.org; Tue, 29 Jul 2025 12:07: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.94.2) (envelope-from ) id 1ugj7E-000Wjl-8D for pgsql-general@lists.postgresql.org; Tue, 29 Jul 2025 12:07:32 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ugj7C-001NJE-1h for pgsql-general@lists.postgresql.org; Tue, 29 Jul 2025 12:07:31 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-60bfcada295so8867496a12.1 for ; Tue, 29 Jul 2025 05:07:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1753790847; x=1754395647; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=j0b4g/sNZTtUzAmA/PlbKegGQGFrZ626Sb47XGEOxTQ=; b=po9cFNplDuwSvr+bcl4mCIME91+SQI8FDAU3mh+HQ8tZmapyen8gP8WLjHtuKvhFLd bkpTa0aKaXU+Xa0HwYHAhIrxN3+dwSp7z5Vo5hoyd2Q+gel2W91rRqIocGGhXk2AGpbF 1DTm3v8p3dTFIKMKopDt359KHU3XRozY1OP/svkThIyd1khs2VCZYtuOLQC/fVZRJ22u Na+AbFz5+qZ33PTDJGWr9fRgg8lM3Vf8WVkbMWDgfQUuWVBDjkQTVV5BQyVqjPUaTc5u +P/hBNuGAcwcD00XDQpRfjhcHYio0u9Z9l9k9AWbVRm9959NsTOd1PuNZFpCY1bmLQpZ WA5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753790847; x=1754395647; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=j0b4g/sNZTtUzAmA/PlbKegGQGFrZ626Sb47XGEOxTQ=; b=NKFnNRoXQeQ8TaYgPxbARif/e4YansNIzQgyMGw8QFDJDsTuVqDA5ubxAEzdYZDlEZ 6VO3A7ASUXR00NzNl+2YnGxowNwu27yxqiv4+L4tIxMZ2d++5LSTQ+i0vqvFFzwTAh9c EjjX4zyju5pK+EbI1Bm1/w2oNE9JTfwBt0ydY7OraaG50oYIS1CV0JFjbhfBT6DcqIHI CGxFCkwFqyP/GUC+2TcPH3yRjP6sJiOdaX8Cnn+KSakQWJbOMnegO94y3jmwKP8h6Krk tGvU0egZ6Y0IJy8w4w4kcdAQK0NBoWC5sFoPW3mlrKStULt9trLZODHj2CaYRATNl+Pk ssAw== X-Forwarded-Encrypted: i=1; AJvYcCWXKHkToEbaHvZff+yT0tdUjgjSiX6MyoxOXClV7wlDm1bj569twERMxFmBwg8afJf/R7Sg0QS3Jbv6Afiz@lists.postgresql.org X-Gm-Message-State: AOJu0YxIZkY4gCgTgRtwpmppqL93yFRhbYdFqllSAMsPGzlVkwp8XZ3a Phrbh/Xhh9Z5fy7pLH2NY0M2uOnV81h7sW0UlLOPskYgpLQ3qEDmPCzBnZy8O0RQa5I= X-Gm-Gg: ASbGnctE5k/CsSPONkxWSzs3fmWy6+pdRu6NNsnz4EUMJ14RzlAjXQU+HSFUNKcPye+ H3BFedQXnJco/VFUkfoXRNgT0a2yQqnkY7LLfKgbW3vkU416+D+ZMIk/2M2zKY75ztd64KD/U6Z 1ydB7m+yJnI8rSOOVHJ2/PLnIcijhsRWWz15+IPjK5rnjg4MvUNb6RRojQooXORk7XMesMkPY2W Fm4odCdMRw7Y984ltq8WK2L9uVWBpMNhq96+qBdwveekwJC1ILL6FaNA8VTJRSBibVo7+/6Ao7J ZznYQTGLlfO8Bt6NAizEdq4Zk86O1+MK9QhPn3UuWPjGUEo/gak8cKztjn679JXkn+3+NRwqGSi 7nlW5NQ6Wn1QZMa3kEXV04i3HvzEdDpbEPD2w6x3T19DXKv5MKlxy X-Google-Smtp-Source: AGHT+IHxqaB4rxhtEmvG7FbY/x7vOJN3j1qhqt1OOfHGYubA7I4QupPW8OJbd6x244vI0gdC7syAMw== X-Received: by 2002:a05:6402:90b:b0:608:3f9c:c69d with SMTP id 4fb4d7f45d1cf-614f1e08468mr15209746a12.33.1753790847302; Tue, 29 Jul 2025 05:07:27 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:260:9b8a:5191:4127:e9f1:710b]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-6156591fe7bsm1075562a12.51.2025.07.29.05.07.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Jul 2025 05:07:26 -0700 (PDT) Message-ID: <2fad4427bff83bc73f9b4215e284a76343f046f2.camel@cybertec.at> Subject: Re: Get info about the index From: Laurenz Albe To: Igor Korot Cc: David Barbour , Jon Zeppieri , Christophe Pettus , Adrian Klaver , "pgsql-generallists.postgresql.org" Date: Tue, 29 Jul 2025 14:07:25 +0200 In-Reply-To: References: <090d8588-e74e-4436-8f69-05ce8624379b@aklaver.com> <0BC8BEBF-3B1F-4E69-A1B9-CCCDF9617168@thebuild.com> <7281c379994ffc70cebb68423f5b8ba339d0d75f.camel@cybertec.at> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-07-29 at 06:46 -0500, Igor Korot wrote: > SELECT > =C2=A0=C2=A0=C2=A0 t.relname AS table_name, > =C2=A0=C2=A0=C2=A0 i.relname AS index_name, > =C2=A0=C2=A0=C2=A0 a.attname AS column_name > FROM > =C2=A0=C2=A0=C2=A0 pg_class t, > =C2=A0=C2=A0=C2=A0 pg_class i, > =C2=A0=C2=A0=C2=A0 pg_index ix, > =C2=A0=C2=A0=C2=A0 pg_attribute a > WHERE > =C2=A0=C2=A0=C2=A0 t.oid =3D ix.indrelid AND > =C2=A0=C2=A0=C2=A0 i.oid =3D ix.indexrelid AND > =C2=A0=C2=A0=C2=A0 a.attrelid =3D t.oid AND > =C2=A0=C2=A0=C2=A0 a.attnum =3D ANY(ix.indkey) AND > =C2=A0=C2=A0=C2=A0 t.relkind =3D 'r' AND -- 'r' for regular table > =C2=A0=C2=A0=C2=A0 t.relname =3D 'your_table_name' -- Optional: filter by= table name > ORDER BY > =C2=A0=C2=A0=C2=A0 t.relname, > =C2=A0=C2=A0=C2=A0 i.relname, > =C2=A0=C2=A0=C2=A0 a.attnum; >=20 > I can build on top of this query, however I have 2 issues: >=20 > 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 quer= ies. 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) Yours, Laurenz Albe