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.96) (envelope-from ) id 1vwUoj-00AUf5-0e for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 00:37:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwUoh-00Bqxb-2C for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 00:37:51 +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.96) (envelope-from ) id 1vwUoh-00BqxS-0Z for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 00:37:51 +0000 Received: from mail-yx1-xb12c.google.com ([2607:f8b0:4864:20::b12c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwUoe-00000001ra0-0jfl for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 00:37:50 +0000 Received: by mail-yx1-xb12c.google.com with SMTP id 956f58d0204a3-64ca6595c8aso2993218d50.0 for ; Sat, 28 Feb 2026 16:37:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772325468; cv=none; d=google.com; s=arc-20240605; b=Naw9wQTZBY2gYTkGaFgzu5bNbr/iqwiALLrpguKJ6o4xoawnmtviHMDn1umIfRzZa/ DhKsddm7w9uJa5wBBzJMXpFHCwvFWxUVo1BYKkied2ygKI5gkVS85a8aXC1OeYQ523UV 2QhFIxFDwYm+cz+HLTuIALGOkvqAEEmURnl6ceCRBmgguQWUOvlb4YC9GGnPa7p1I/zv gx810aWaYMOot5XYKTQ/D+tXYzL0LHqVv8BN4Ul95Fk3CRym4U99tVJIKrhhSFT97KFy OZNKDw71qyqdGhfOX36GaNGli4/TYEi2ppl7mNEOAAMD7WteU6DoC/dyDdeJmG9LqZGC ETQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=wUApEWbrUv8QEzkEt9IAFzEzfyju5PJ8aF0Qll2JsFY=; fh=FkumTO2HZBJ0xxDCHQf1NWXYJ+eJe/NEywMjiSqLc4c=; b=eAmz2MKJ+gFDFvno4XfYcjf3JV4B17AMM1DCWp9TWKE7PQKMWQcaQFKFppjFdSLLrg oeQ5Ru3hM45vA1Fq8UpRjj6e7eoZonIKrpqS5Jti8mF+yYN9d/ZPFMEbqQgdkuPaEIGc GgOpQvXAsO73C+MxDl1AlrntVxBeMfQXQE1rlGBNnEKnSi1UO1VAEAikDdTpTspwUsfJ UojGL+cSGnee3qrrqPTdF/tAp2FrdaqYl43t/RD5SbU4UfCGseGFKlV9KQh/jKXic8V+ 0m+k5DA++uDgM6BYZv2fiFKli/W7svRZ21izSVlKXwTaC5cuQXvjGa+xErS4jqewjeqD bfvQ==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772325468; x=1772930268; darn=lists.postgresql.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=wUApEWbrUv8QEzkEt9IAFzEzfyju5PJ8aF0Qll2JsFY=; b=e3teAE4mlysJUl1yMw1kDLnqWRuC5uksCq/0xwyfCo5mkvQt4GULOh8wd/eDyGUEos oy/qMylBW4VEjkZOUGFGS1ZqNo+FXUAzj5snGv2hb3ysRnPm8I5qxQg2+cnBH4stiO6m Nri5LDi2LXLTshxh1Zv7yK9SEiQcMGsDcFjqm+fWNRq/575PO4BpP9picacmY36JWJE/ moXTkN+5SeivgN25jHHh2OP/W5iYUaKayturYWp05ZKdJO2oX9tNtQN+wtcewpqsH50p tV+Si9TPVF5qoIC1amYgq7qpwwxy3arVvmbtD5sCflhAfSY4qnkE8XTvALVl5iY3cOQF ArXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772325468; x=1772930268; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wUApEWbrUv8QEzkEt9IAFzEzfyju5PJ8aF0Qll2JsFY=; b=cwR/0qGsE3FCk9BRYrJsLhBejG/uGBXMgNuolCpcAHvtVC9098bpjzOu5DSX38r8Et uN80RAWtHO3EUdi8fYvy49DHjnnLaLBysMrC/QmcNkby9qr/GHypXxLvoZPa31Jyq44u rZHgjYS6Gz1JUhl7XGPEZ6atLHdhzHPyj6M+OS4Yw/IDBm50Z9qUDIBcCh35KKjeetVT 18vEepAZAbvoZ1NaOs21BHvrYgbOZxjOiXFpZFlEkyNwUHEjytsqXL9c1dDhLEEs/Gdc Yr6xGC7DR5iUcBw8Z0tREyJtyZGw7p/7Ej8DNkPyZX8G+EQs18vIHbkN18cxAQrWRlj3 /jDg== X-Forwarded-Encrypted: i=1; AJvYcCWhstECuOLnqNoeG79cCxjBFlT70bpwwGVAWT27mU+oJnvd0vJORZTga9LhjUpjcxE0gjlRq9jRFI6AfnN+@lists.postgresql.org X-Gm-Message-State: AOJu0YxBh3smtfjCVUFvFqNcMpJjNzEYuA7DVeGuXmNSl4IMqKBVXuM6 y+pvjXiYnCPXKOCZcvf9JPh9g7k/3utYqw1ks00nvBljxNetqrhQaOpim7WOPzoGHpDNpfAk731 QiOcgRlBtbX02DuBENgIuQ922k/Gncjg= X-Gm-Gg: ATEYQzwweFLAjQOTuWbK0uXwTBJ8pAF0jl/dEEZ2iwo5NSN1r6hVR4vs2OHnXlXWPNt WqSeTo6SgHWtN+uBhaY2rF0jvUyRm6XulhM31QfqELNmAEbns/2XFOnivqViMppL+9unlYCkVY4 N9L9mGGKePuzg1//JUZED4V4EDxxBRvf4Yh1d+jaFwO2tjrdhylXg7lLTdDMDI3s1uVApUwImwu KEDSZfOLuBXWn/NjE263vP5w9K7RBj++w1P8DriUVe6FEwSPTUaAKmJ/4ATvZmXYR6elt7WcFdo XqHDHWZ/v2HVhJ808wXyGcJdFPQg22AX X-Received: by 2002:a05:690e:14c6:b0:64c:bfd0:ad6f with SMTP id 956f58d0204a3-64cc2144f26mr6890561d50.33.1772325468506; Sat, 28 Feb 2026 16:37:48 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Sat, 28 Feb 2026 18:37:34 -0600 X-Gm-Features: AaiRm50-LtXstR-b4dliT5hGzUWHALrStYlEcaoJUUkRgwKzK5zMMGPjMeRTcoo Message-ID: Subject: Re: Where the info is stored To: "David G. Johnston" , "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, David, On Fri, Feb 27, 2026 at 10:18=E2=80=AFAM David G. Johnston wrote: > > Please keep replies on-list. > > On Mon, Feb 16, 2026 at 5:49=E2=80=AFPM David G. Johnston wrote: >> >> On Monday, February 16, 2026, Igor Korot wrote: >>> >>> >>> Where are included columns >>> >>> >> >> pg_attribute, though you need info from pg_index to interpret the conten= ts. > > > Specifically: > > \set ON_ERROR_STOP on > > BEGIN; > > CREATE TABLE wip_idx_include_demo ( > id integer NOT NULL, > secondary_id integer NOT NULL, > included_payload text, > notes text, > CONSTRAINT wip_idx_include_demo_id_secondary_uq > UNIQUE (id, secondary_id) INCLUDE (included_payload) > ); > > WITH idx AS ( > SELECT i.indexrelid, i.indrelid, i.indnkeyatts, i.indkey::int2[] AS i= ndkey > FROM pg_index i > JOIN pg_class ic ON ic.oid =3D i.indexrelid > JOIN pg_namespace ns ON ns.oid =3D ic.relnamespace > WHERE ns.nspname =3D 'public' > AND ic.relname =3D 'wip_idx_include_demo_id_secondary_uq' > ), ords AS ( > SELECT idx.indexrelid, > idx.indrelid, > idx.indnkeyatts, > s.ord, > idx.indkey[s.ord] AS attnum > FROM idx > CROSS JOIN LATERAL generate_subscripts(idx.indkey, 1) AS s(ord) > ) > SELECT ns.nspname AS schema_name, > ic.relname AS index_name, > tc.relname AS table_name, > a.attname AS column_name, > CASE WHEN ords.ord < ords.indnkeyatts THEN 'key' ELSE 'include' END A= S column_role, > ords.ord + 1 AS index_position > FROM ords > JOIN pg_class ic ON ic.oid =3D ords.indexrelid > JOIN pg_namespace ns ON ns.oid =3D ic.relnamespace > JOIN pg_class tc ON tc.oid =3D ords.indrelid > JOIN pg_attribute a ON a.attrelid =3D ords.indrelid > AND a.attnum =3D ords.attnum > AND NOT a.attisdropped > ORDER BY ords.ord \gx > > \d+ wip_idx_include_demo_id_secondary_uq > --given that the above provides the relevant info Greg's suggestion would= also get you a functioning base query. > > ROLLBACK; Just tried the following: draft=3D# CREATE TABLE leagues_new(id serial, name varchar(100), drafttype smallint, scoringtype smallint, roundvalues smallint, leaguetype char(5), salary integer, benchplayers smallint, primary key(id) INCLUDE (drafttype, scoringtype) WITH( fillfactor =3D 50 )); CREATE TABLE draft=3D# draft=3D# draft=3D# SELECT co.conname AS name, ( WITH idx AS( SELECT i.indexrelid, i.indrelid, i.indnkeyatts, i.indkey::int2[] AS indkey FROM pg_index i, pg_class ic, pg_namespace ns WHERE ic.oid =3D i.indexrelid AND ns.oid =3D ic.relnamespace AND ns.nspname =3D 'public' AND ic.relname =3D 'leagues_new' ), ords AS ( SELECT idx.indexrelid, idx.indrelid, idx.indnkeyatts, s.ord, idx.indkey[s.ord] AS attnum FROM idx CROSS JOIN LATERAL generate_subscripts(idx.indkey, 1) AS s(ord) ) SELECT a.attname FROM pg_attribute a, ords WHERE a.attrelid =3D ords.indrelid AND a.attnum =3D ords.attnum AND NOT a.attisdropped AND ords.ord > ords.indnkeyatts ) AS include, n.nspname AS tablespace, cl.reloptions AS with FROM pg_constraint co, pg_namespace n, pg_class cl WHERE co.contype =3D 'p' AND n.nspname =3D 'public' AND cl.relname =3D 'leagues_new' AND cl.oid =3D co.conrelid AND n.oid =3D cl.relnamespace; name | include | tablespace | with ------------------+---------+------------+------ leagues_new_pkey | | public | (1 row) draft=3D# As you can see only the constraint name and the tablespace are populated correctly. I'm trying to get all the info in one hit from the ODBC based solution, hence the huge query. Do you see a way of improvement? Thank you. > > David J. >