# -*- mode: snippet -*-
# name: qp_session
# key: qp_session
# group: vertica
# expand-env: ((yas/indent-line 'auto) (yas/wrap-around-region 't))
# https://www.vertica.com/kb/System-Tables-For-Performance/Content/BestPractices/System-Tables-For-Performance.htm
# --
SELECT DATE_TRUNC('second',query_start::TIMESTAMP),
       session_id,
       transaction_id,
       statement_id,
       node_name,
       LEFT(query,100) query,
       ROUND((query_duration_us/1000000)::NUMERIC(10,3),3) duration_sec
  FROM query_profiles
 WHERE session_id = '$1'
   AND query_duration_us > 60000000
 ORDER BY duration_sec DESC;$0
