| From: | Igor Korot <ikorot01(at)gmail(dot)com> |
|---|---|
| To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
| Cc: | "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Where the info is stored |
| Date: | 2026-03-01 07:50:52 |
| Message-ID: | CA+FnnTxc_8-GfyPM12D+w5i8+VXVsUzAcfpYjRYKqsxC5Rr3zw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi, David,
On Sat, Feb 28, 2026 at 11:49 PM David G. Johnston
<david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
>
> On Saturday, February 28, 2026, Igor Korot <ikorot01(at)gmail(dot)com> wrote:
>>
>>
>> draft=# 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 = i.indexrelid AND ns.oid = ic.relnamespace AND
>> ns.nspname = 'public' AND ic.relname = 'leagues_new' )
>>
>>
>
> I doubt your index name is leagues_new. That is probably the table name. But ic.relname contains index names.
With some trial and error I think I finally get the query right ;-)
draft=# SELECT c.relname AS name, ixs.tablespace,
-- Get included columns (PostgreSQL 11+)
ARRAY(
SELECT a.attname
FROM pg_attribute a
WHERE a.attrelid = idx.indrelid
AND a.attnum = ANY(idx.indkey)
AND a.attnum > 0
ORDER BY array_position(idx.indkey, a.attnum)
OFFSET idx.indnkeyatts
) AS included,
c.reloptions AS storage
FROM pg_index idx, pg_class c, pg_namespace n, pg_class t, pg_indexes ixs
WHERE ixs.indexname = c.relname AND c.oid = idx.indexrelid AND t.oid =
idx.indrelid AND n.oid = c.relnamespace AND idx.indisprimary AND
n.nspname = 'public' AND t.relname = 'leagues_new';
name | tablespace | included | storage
------------------+------------+-------------------------+-----------------
leagues_new_pkey | | {drafttype,scoringtype} | {fillfactor=50}
(1 row)
draft=#
Thank you for sticking with me and sorry for the trouble.
I am getting everything in one DB hit and the query is not that big.
I am only worrying about tablespace filtering but I think I got it
right.
Thx once again.
P.S.: If you see any improvement - please by all means do let me know.
>
> David J.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Igor Korot | 2026-03-01 07:58:37 | Re: Where the info is stored |
| Previous Message | David G. Johnston | 2026-03-01 05:49:13 | Re: Where the info is stored |