Prod Redshift cluster, many users are executing this query against pg_catalog tables

0

We have a mixture of Redshift users querying their own tables and this query against pg_catalog tables. The bulk of the users are QuckSight-specific users. Why is this query being run?

SELECT c.oid, a.attnum, a.attname, c.relname, n.nspname, a.attnotnull OR (t.typtype = 'd' AND t.typnotnull), pg_catalog.pg_get_expr(d.adbin, d.adrelid) LIKE '%nextval(%' FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) JOIN pg_catalog.pg_attribute a ON (c.oid = a.attrelid) JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = a.attrelid AND d.adnum = a.attnum) JOIN (SELECT 3285788 AS oid , 2 AS attnum) vals ON (c.oid = vals.oid AND a.attnum = vals.attnum)

I discovered this in the SYS_QUERY_HISTORY view.

Lynne F
질문됨 2달 전356회 조회
1개 답변
1
수락된 답변

That is a simple catalog query that shows information about a column in a table.

SELECT c.oid, a.attnum, a.attname, c.relname, n.nspname, a.attnotnull OR (t.typtype = 'd' AND t.typnotnull), pg_catalog.pg_get_expr(d.adbin, d.adrelid) LIKE '%nextval(%' 
FROM pg_catalog.pg_class c 
JOIN pg_catalog.pg_namespace n ON (c.relnamespace = n.oid) 
JOIN pg_catalog.pg_attribute a ON (c.oid = a.attrelid) 
JOIN pg_catalog.pg_type t ON (a.atttypid = t.oid) 
LEFT JOIN pg_catalog.pg_attrdef d ON (d.adrelid = a.attrelid AND d.adnum = a.attnum) 
JOIN (SELECT 3285788 AS oid , 2 AS attnum) vals ON (c.oid = vals.oid AND a.attnum = vals.attnum)

JOIN (SELECT 3285788 AS oid , 2 AS attnum) vals is the critical piece here.

  • 3285788 is the unique OID for a table (pg_class).
  • 2 is the column number for table (pg_attribute).
  • It is an equal join so it only retrieves data for this one column.

So the query is getting the column name, nullable, and default value if any from that particular column. If you are seeing it a lot, QuickSight might be executing this for every column.

I would expect this is being done by QuickSight in order to build queries needed for reports.

profile pictureAWS
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
profile pictureAWS
전문가
검토됨 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠