On Fri, 21 May 2021 at 09:57, David Christensen
<david.christensen@crunchydata.com> wrote:
> CREATE TEMP TABLE fail (a INT PRIMARY KEY);
>
> SELECT att.attname
> FROM pg_index i
> JOIN pg_class d ON d.oid = i.indrelid
> JOIN generate_series(1, 32) col(i) ON col.i <= i.indnatts
> LEFT JOIN pg_attribute att ON att.attrelid = d.oid AND att.attnum = i.indkey[col.i - 1]
> WHERE d.relname = 'fail';
>
> ERROR: cache entry already complete
Thanks for reporting this.
I've just had a quick look so far. EXPLAIN VERBOSE shows that for some
reason the join to pg_attribute.attrelid is unique.
Nested Loop Left Join (cost=8.59..55.40 rows=11 width=64)
Output: att.attname
Inner Unique: true
I'm not quite sure why it came to that conclusion, there's certainly
no unique index on that column.
I'll keep looking to see what the problem is there.
David