WITH tables AS (
SELECT DISTINCT table_name,
table_schema,
column_name,
ordinal_position AS pos
FROM svv_columns
WHERE table_schema NOT IN (‘pg_internal’,‘pg_catalog’,‘information_schema’)
)
SELECT table_name, table_schema, column_name
FROM tables
WHERE
HAS_SCHEMA_PRIVILEGE(table_schema, ‘USAGE’) AND
(
table_schema IN (SELECT schemaname FROM SVV_EXTERNAL_SCHEMAS) OR
HAS_TABLE_PRIV

above query from redash is causing high cpu in our redshift cluster,is it because of some particular tab/refresh being hit multiple times?

any insights would be helpful

@mfrye i saw you mentioning about doing some hack to the query,can you please provide the exact query updated to fix this

I don’t think what I did is relevant here. My query modified the SVV_EXTERNAL_SCHEMAS, so I could force Redash to show columns the user didn’t have permission to in the schema columns list.

Without looking at much else and just guessing, but perhaps you have many tables with lots of columns?

The end of that query seems to be missing?