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 1vwZSY-00Fq4J-1C for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 05:35:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwZSW-00CNnz-0P for pgsql-general@arkaria.postgresql.org; Sun, 01 Mar 2026 05:35:16 +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.96) (envelope-from ) id 1vwZSV-00CNnr-2N for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 05:35:15 +0000 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwZSS-00000001pQp-1pDs for pgsql-general@lists.postgresql.org; Sun, 01 Mar 2026 05:35:15 +0000 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-79854193a54so31711277b3.3 for ; Sat, 28 Feb 2026 21:35:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772343311; cv=none; d=google.com; s=arc-20240605; b=e+5rQqaZrl/N3tg32+lsETkgTeIlzuyPXFcAIXBaQ+za/FjqXrnGxdFG1kEDYPeynt u0mQxLa8weIsO/1HRXQGCA3Y5VMlDb2ajgaoluCONzV98McnFFuOHSlqQuL6alV0iVaz p8J+TjhhfTV9hPPq+SmB4v7rAsilMQbPIQbBN09WaKQz/Utj6BrbMOJf/+P2C9lcJrTZ bDR+g6sHodnClxoyiEGtL8sqi6VML0gAAup5peBAmAYErd1LZsGr6FOgBN0juTZETg0A /abYD+7xcI46gIpUmXzcOjdnA0oD2wuWLaNVGhaZnAYbS+dav2Jxye6BKfqztLOHOLGJ jGTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Tl6Lv+zmTO9dLa1TvzLtlzjJyfMKewvwaM2YXdD9uRw=; fh=kyAsYl77KsxRDd0MpChrI1Mi1G/EXxKHRVc31UaZmY8=; b=VWcTfiY75acrmFgRn/4fy6H2ikbV6Jd+WCqfz+3Di1pidha3G5wIPlSv3ho7vxKsvF /51mO2zHP3hA/wzDx9cHbZ3t9RG1ZJnMSHdfvhl96yX4mRm7m3PO0PEujh9zpoEhDU1G uAfp6LBHy/rOnvbsPKR6Sdnpx/WNffECbEdqoADybyd6XuzNRad6YJ2uoZyKEOwsNxof kmLODFKA51XxhPVlHjuCko58ClepEfDxyvCPaBOJuta7risIB4BkkEb2JEhbbl4KQibP 9rbp86756Jcg5t6pXT4DearZNUsTjN2BY/ohLnjkqulUEKQS2rB9kuCuKITbUuQ05eRO pwvg==; 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=1772343311; x=1772948111; 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=Tl6Lv+zmTO9dLa1TvzLtlzjJyfMKewvwaM2YXdD9uRw=; b=ApKyj4E/Z+GiIm/NgGkjoGJs86BZQjjvNn7wwXfdJFF6i15bUHxmXy/My8lIHlGYpJ if+4Ow6C7IS50jX7ZDj3+LD6vHtxVDzBIKgeDEJGaqO/+xycr9zBRfQe7Sabb8MLaP5h Met/y49EUrIPNKj36mDxeyyHc/4VIXatb9Qn0GD8THGYtKeWGbblHoB8/baAK4kVx1oe BM0z2QnDfJKQaFmLv9/lMMcYNRC2a0TuLotAgRh2QhjNjmFGScbTWBn96IJs6T7NLaGn FdgeW01kokT9/As7eSFBZXVBpAkZDJ8juQvtfCGFI1BGP+xJ3cVZ7PoqF2bOSGTvL+ap DrLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772343311; x=1772948111; h=content-transfer-encoding:cc: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=Tl6Lv+zmTO9dLa1TvzLtlzjJyfMKewvwaM2YXdD9uRw=; b=LANqkeAoWxmPA08DpBQRhGeEpOrPn4pGbg3BqiVAtYWPErfrx9Fhq+8SzRjKOh8ZSh T6RwlJg3Yxz4pFpTpThljdPsoAw2vb7sVngfHYgDjUrgGw2alrwBPa0Zm7UPcqoy1w5g tQZD1ROYMvsPYVvs7T+qTIA4OmAEw6Vd4hQNJUS2V5yBZXXxyf4aUWanAxznn8VHD6KR ksMGUre5FUdqF8nRVdaOexfRXjGUrzo2h6jZbe/aoLKNgH7264if8ZpMOARJfNlBmRJQ GbYRsKGhn0yFechQ72KI2ea3ulQnKRbVXQwKJ9x2lK0dEsXMutW4HVJgnmVQZQAf6D/M 4Vwg== X-Gm-Message-State: AOJu0Yy7Do8+/eAeYd1kPExr5+Jd0rpdj3fvKLvwN4OnUkJEG0vXPvds kTI3PwGbr+OBT0lJsfvMZMRP6lg5IwfkuLkn2YtVxFLnHJcz1Kp0bVpcqSfEcitGwnsLrf4TuYt BdNHRcOZCt9hoT0cepvGa1cHMPe4qaV0= X-Gm-Gg: ATEYQzw1xl8tT7LUhRvTmHcaossUm0wNh0GrREHl8CMira6aHtwYscFTUYzQBRP85Cm lOUNFVEgedKgXNCwSYWGOjl5GeQmdj/Hm20WiH2qmRbq/KQgaMZzTrMya9ujdLawiq3inYOvi1U lR5n62diVwZ3/smhF5uJqCrU1qt5ABQqu+ph27fTv1FXpXaowjXvfcweGI4YGxej4bDKcJKOrzB wbFcMQpWkNDsdSUg5zz2n4xbyZgCWo3pPmrwz1e8MCNS0ZkkfYIaUx2VVrWQPB0dRKb56bbNwoe fbVRsJ/SaUhOmZL+wsdCvA== X-Received: by 2002:a05:690c:60c4:b0:798:6666:26bd with SMTP id 00721157ae682-7988557f476mr84264987b3.37.1772343310616; Sat, 28 Feb 2026 21:35:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Igor Korot Date: Sat, 28 Feb 2026 23:34:58 -0600 X-Gm-Features: AaiRm534_MMidgkyx93htIWmJq35Rv0aRQwroSaHdZgNyUopMgCR6SWH8b7_6-s Message-ID: Subject: Re: Where the info is stored To: "David G. Johnston" Cc: "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 Sat, Feb 28, 2026 at 7:42=E2=80=AFPM David G. Johnston wrote: > > On Sat, Feb 28, 2026 at 6:34=E2=80=AFPM Igor Korot w= rote: >> >> And why there is no WHERE populated? >> >> Thank you. >> >> On Sat, Feb 28, 2026 at 7:05=E2=80=AFPM Igor Korot = wrote: >> > >> > Hi, David, >> > >> > On Sat, Feb 28, 2026 at 7:02=E2=80=AFPM David G. Johnston >> > wrote: >> > > >> > > On Saturday, February 28, 2026, Igor Korot wrot= e: >> > >> >> > >> FROM pg_constraint co, pg_namespace n, pg_class >> > >> >> > >> As you can see only the constraint name and the tablespace are >> > >> populated correctly. >> > > >> > > >> > > Constraints don=E2=80=99t have included columns. Only indexes do. = You need to query the index, not the constraint. >> > >> > I literally copied your query into my code and it didn't populated >> > anything... >> > >> > Am I missing something? >> > > I trimmed your query to emphasize/point-out that you were querying pg_con= straint and that doing so to find included columns is doomed to failure (I = suppose it could have been used to find the index, but in this case it wasn= 't. I haven't explored that approach.). You should step back and consider= why you thought the fragment I included in my reply, a bare FROM clause, w= ould somehow be executable since it is in no way a valid query. draft=3D# 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 ns.nspname, ic.relname, tc.relname, a.attname, CASE WHEN ords.ord < ords.indnkeyatts THEN 'key' ELSE 'include' END, ords.ord + 1 AS index_position FROM pg_attribute a, ords, pg_class ic, pg_namespace ns, pg_class tc WHERE a.attrelid =3D ords.indrelid AND a.attnum =3D ords.attnum AND NOT a.attisdropped AND ic.oid =3D ords.indexrelid AND ns.oid =3D ic.relnamespace AND tc.oid =3D ords.indrelid AND ords.ord > ords.indnkeyatts; nspname | relname | relname | attname | case | index_position ---------+---------+---------+---------+------+---------------- (0 rows) draft=3D# This is an exact replica of your query from the first post where you put it= . I only removed AS statements. As you can see 0 rows are returned. Thank you. > > David J. >