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 1ugjHs-006lz8-Hi for pgsql-general@arkaria.postgresql.org; Tue, 29 Jul 2025 12:18:33 +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 1ugjHr-000e2T-4F for pgsql-general@arkaria.postgresql.org; Tue, 29 Jul 2025 12:18:31 +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 1ugjHq-000e2K-Pr for pgsql-general@lists.postgresql.org; Tue, 29 Jul 2025 12:18:31 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ugjHn-001Tnp-2o for pgsql-general@lists.postgresql.org; Tue, 29 Jul 2025 12:18:30 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e8e21bbd736so1274182276.3 for ; Tue, 29 Jul 2025 05:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753791507; x=1754396307; 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=HmTAwZbBMV7utUFUr/E1EHUX5cWiuSMouFV/wBxeMpY=; b=iNBXMvaAOqwi9Gm1MNluBuv+J+1xMxq48sWFo38sTIPDDvs+IFsW470BEWdhQhuxdN G6VxPY5MIcIS55llasYwfbP3h5ugE9V9VZxlRi4vsKHHQ8vzO5VnN/C+wTPvLwRXOP3E nN+1oV9566SPuk7GESIPzAI63/+eg4vvA2ycr0mEj9YRzOywCAo2/zmJ6tcGLY23LwUF G8WJmixvaL//hZwWZlAHn/mNOSxr5lWI/DG5llXrsSWaaP0I4wX2pz5NwVAQC51Ku6D/ NiMn3h1dhpKUHlk8DHNQhGsmbFGd0HF/cHgqVqvKO/B6qQhnlVkyh3vKC2i7cxro2+iR /sbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753791507; x=1754396307; 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=HmTAwZbBMV7utUFUr/E1EHUX5cWiuSMouFV/wBxeMpY=; b=lCqm44dcdL6YDFPU4EeM6RifM4MXUjiQha7s19pkpFpouxsBwyFUPsYQ4A47IYhBGf MCdrvn2rKHtFjmkHR2QBERr2u2ugRm6mOAK4q4y9PgQoMJRHPcw+YSCYfmWVulGL2FaV pB0g+f/tg8A0rRp3wjQlCuyrAxMjuy+fKTlPbIIiPM4t1YHCRZHo0JTrC5ROllVF2EUs u2RypxJ2pl/eST+17EB2FCVCu6Kcmia9c3elbNplva/NYOx60v0BRcPXarhLL+cEQKSo j4kFf+cctqCNuzV4uh7AXbgsh9o6w1jO6H5H94TAwv3FKQR83a2YY8xMUvwPS2oQS1Wv k1ew== X-Forwarded-Encrypted: i=1; AJvYcCWpvTPN2OuVdHGtCdDTOF4Y6I8eKwHCU4mJpZuvDHtqgi/r+AoebGmvZwc06HVHRONc4HCLDcEe85y8qWHc@lists.postgresql.org X-Gm-Message-State: AOJu0YwO5NOS8xD34Rtu3/GQtswSH5qP6LjjXDI0Tmsa8mxlWZiBsZpB MleD0ELwSU4NJ4xGhfliSfCECAKSpMwUbmSYOwqdcMI7qUsbo6d60ktVsXmgUW3jvPGdKhed0ze Xwa5LctEvZMTNo2VqaRXyF2D9mwY3XM4= X-Gm-Gg: ASbGncsbTb7nPajG2nJk8AmUD+bIENI0+vRnG5nnB7YWTChhdAhJ4hKR92GZBSPipSO 7N/gvj8cniVtICTfuDYouyzH8WZlB38j0TMoRXb183hxT0iBe/LNIZZWKTgfbNDF37AldEzD2VQ MBi+tpLz6bWGycmgCK29sFnQMu1m0m7x4txNOz82KryHR8oX+WTgv7mdzUCFLkYU/XOR32qMQ0J X3hjOMJ4Gd9YF4Y1nRzug== X-Google-Smtp-Source: AGHT+IGlJLbOb0u1w5HNpxFCbxaEVecFtim/ypV9mBNtji/9xNt6/2Ou3fgBxQzjdAlV+O9FzlgVfR5Rfbk3GOzXVs8= X-Received: by 2002:a05:690c:55c2:20b0:71a:186:59af with SMTP id 00721157ae682-71a01866e86mr89182917b3.30.1753791506480; Tue, 29 Jul 2025 05:18:26 -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: Tue, 29 Jul 2025 07:18:15 -0500 X-Gm-Features: Ac12FXyez_oQLAyKQahI-7yiYUPNzJbBI1A2636IB8En9lEzzESwU_84BL-Z9rg 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 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. The reason I'm asking this is because I want to have the same interface for different DBMSes. But it also made me curious. If I have a database for some financial data for the year 2024 in the mydb_2024 and I have current year financial data in the mydb_2025 how can I compare the data? > > 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 Thank you.