title: How can I find the users that queried a view in Redshift?
body: <p>Hello everyone and thank you in advanced!</p>
  
  <p>I'm having trouble to find a query to get a list of users that have queried some specifics <strong><em>views</em></strong>.
  A example to clarify, if I have a couple of views </p>
  
  <p><strong>user_activity_last_6_months</strong> &amp;</p>
  
  <p><strong>user_compliance_last_month</strong></p>
  
  <p>I need to know who is querying those 2 views and if posible other statistics. This could be a desired output.</p>
  
  <pre><code>+--------+-----------------------------+----------+----------------------------+----------------------------+----------------+-------------------+----------------------+------------------+
  | userid |          view_name          | queryid  |         starttime          |          endtime           | query_cpu_time | query_blocks_read | query_execution_time | return_row_count |
  +--------+-----------------------------+----------+----------------------------+----------------------------+----------------+-------------------+----------------------+------------------+
  |    293 | user_activity_last_6_months | 88723456 | 2018-05-08 13:08:08.727686 | 2018-05-08 13:08:12.423532 |              4 |              1023 |                    6 |              435 |
  |    345 | user_compliance_last_month  | 99347882 | 2018-05-10 00:00:03.049967 | 2018-05-10 00:00:09.177362 |              6 |               345 |                    8 |              214 |
  |    345 | user_activity_last_6_months | 99347883 | 2018-05-10 12:27:36.637483 | 2018-05-10 12:27:44.502705 |              8 |                14 |                    9 |               13 |
  |    293 | user_compliance_last_month  | 99347884 | 2018-05-10 12:31:00.433556 | 2018-05-10 12:31:30.090183 |             30 |                67 |                   35 |             7654 |
  +--------+-----------------------------+----------+----------------------------+----------------------------+----------------+-------------------+----------------------+------------------+
  </code></pre>
  
  <p>I have developed a query to get this info but for tables in the database using system tables and views, but I can't find any clue to get the same results for views.</p>
  
  <p>As I've said, the first 3 columns are mandatory and the others will be nice to have. Plus, any further information is welcome!!</p>
  
  <p>Thank you all!!</p>