select a.relname as indexname,b.attname as colname from pg_class as a, (select attname,attrelid from pg_attribute where attrelid in (select oid from pg_class where relname in (SELECT  c.relname AS index_name FROM (SELECT relname,indexrelid FROM pg_index i, pg_class c WHERE c.relname = 'sku_attributes' AND indrelid = c.oid) t, pg_index i,pg_class c WHERE t.indexrelid = i.indexrelid AND i.indexrelid = c.oid))) as b where a.oid=b.attrelid group by indexname,colname;