-1

I am trying to find the amount of data queried per statement from AWS Lambda on Redshift, but all I can find is amount of data queried per query ID. There are multiple lambdas which I am running but I can't seem to relate the lambdas to the query ID.

I tried to look up the documentation on AWS Redshift system views, but there doesn't seem to be any tables which contain these values.

  • 1
    Please indicate what you are looking to find in the difference between data returned for a statement vs. a query? Are you looking for data returned from a FETCH? Or are you looking for data scanned and not data returned? – Bill Weiner Mar 24 '22 at 15:44
  • Hi, I am trying to locate the query ID for a given statement that is executed using AWS lambda. After I run a lambda function, I want to find out how much data is queried using that lambda function. For reference, I am trying to see how much data is queried for each function, similar to this: https://aws.amazon.com/premiumsupport/knowledge-center/redshift-spectrum-query-charges/ However, I can't seem to find a way to relate the query ID to a function. May I know if that makes sense? – charlieMike Mar 25 '22 at 16:19

1 Answers1

1

So there are a few ways to do this. First off the Lambda can find its session id with PG_BACKEND_PID(). This can be reported out / logged from the Lambda to report all statements from this session. Or you can add a unique comment to to all the queries coming from Lambda and you can search on this in svl_statementtext. Or you can do both. Once you have the query id and session id you look at the query statistics (SVL_QUERY_REPORT or other catalog tables).

Be aware that query ids and session ids repeat over time so also check the date to make sure you are not seeing a query from some time ago.

Bill Weiner
  • 8,835
  • 2
  • 7
  • 18