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년 전

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

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

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

관련 콘텐츠