Objects used in queries

0

Hello, is there any way to find out the list of all the tables (including external tables) used in the sqls executed in redshift. What I am looking is if there is any view or table which says this query has accessed these tables, if there is such view/table it would be easy to extract the info I am looking for. Otherwise I would need to go query history and manually get the objects accessed in each query.

nmakb
已提问 5 年前371 查看次数
1 回答
0
已接受的回答

Hi nmakb,

I believe you can construct query or view for what you're looking by basing a query off of a UNION of query system log table pg_catalog.stl_scan jointed to a few other table for all table in Redshift storage UNIONEed with a query of svl_s3query smilarly joined to a few other tables to get the query text and the table and schema name.

Basically stl_scan tracks all table scan operators against table in Redshift storage for in all query plans and svl_s3query effectively does the same because all Spectrum sub-queries are single table in nature and produce equivalent scan results returned to the slices from the Spectrum layer.

I hope this helps you develop the result set you're looking for.

Regards,
-Kurt

klarson
已回答 5 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则