- Newest
- Most votes
- Most comments
The issue with your query is that the PID column in Redshift is indeed not unique and gets reused, making it difficult to accurately match queries with specific SSL connections. Here's an improved query that will help you identify queries running over TLSv1 connections:
SELECT q.query AS query_id, LEFT(q.querytxt, 500) AS query_text, q.starttime AS query_start_time, c.recordtime AS connection_time, u.usename AS user_name, c.sslversion, q.database, DATEDIFF(seconds, q.starttime, q.endtime) AS duration_seconds, q.aborted FROM stl_connection_log c JOIN stl_query q ON c.pid = q.pid AND q.starttime >= c.recordtime AND q.starttime <= DATEADD(minute, 60, c.recordtime) JOIN pg_user u ON q.userid = u.usesysid WHERE c.sslversion LIKE 'TLSv1%' AND c.recordtime >= DATEADD(day, -7, GETDATE()) AND q.userid > 1 ORDER BY c.recordtime DESC, q.starttime LIMIT 500;
This query joins the STL_CONNECTION_LOG and STL_QUERY tables with a time-based condition to ensure that queries are associated with the correct connection. It looks for queries that started after a TLSv1 connection was established and within a reasonable time window (60 minutes) of that connection.
If you need to analyze query wait times or execution details for these TLSv1 queries, you could also join with STL_WLM_QUERY to get information about queue times and execution times, or with SVL_QLOG for a more comprehensive log of query execution.
For more detailed analysis, you might want to adjust the time window or add additional filters based on specific users or databases that you suspect are using the deprecated SSL versions.
Sources
Reviewing queue wait times for queries - Amazon Redshift
SVL_QLOG - Amazon Redshift
Relevant content
asked 7 months ago
asked 4 years ago
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago
