Skip to content

Instantly share code, notes, and snippets.

@jackghm
Created February 25, 2015 18:26
Show Gist options
  • Save jackghm/7747a0c00ea595f5cab8 to your computer and use it in GitHub Desktop.
Save jackghm/7747a0c00ea595f5cab8 to your computer and use it in GitHub Desktop.
Vertica Query request times over time by user
-- Query request times over time by user
select distinct TheDay, user_name
, (min_dat / 1000) as min_sec, (max_dat / 1000) as max_sec
, (avg_dat / 1000) as avg_sec, (median_dat / 1000) as median_sec
, query_cnt
from (
select DATE(end_timestamp::timestamp) as TheDay, user_name
, min(request_duration_ms) over(partition by DATE(end_timestamp::timestamp), user_name ) min_dat
, max(request_duration_ms) over(partition by DATE(end_timestamp::timestamp), user_name ) max_dat
, avg(request_duration_ms) over(partition by DATE(end_timestamp::timestamp), user_name ) avg_dat
, median(request_duration_ms) over(partition by DATE(end_timestamp::timestamp), user_name ) median_dat
, count(*) over(partition by DATE(end_timestamp::timestamp), user_name ) as query_cnt from query_requests
where is_executing is false
and request ilike '%table%'
-- and user_name ilike '%Elvis%'
and not (request like 'SELECT * FROM columns%' OR request like '%query_requests%') ) my_alias
order by 1, 2 desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment