Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in BI by (17.6k points)

I'm kicking tires on BI tools, including, of course, Tableau. Part of my evaluation includes correlating the SQL generated by the BI tool with my actions in the tool.

Tableau has me mystified. My database has 2 billion things; however, no matter what I do in Tableau, the query Redshift reports as having been run is "Fetch 10000 in SQL_CURxyz", i.e. a cursor operation. In the screenshot below, you can see the cursor ids change, indicating new queries are being run -- but you don't see the original queries.

Is this a Redshift or Tableau quirk? Any idea how to see what's actually running under the hood? And why is Tableau always operating on 10000 records at a time?

Redshift console

1 Answer

0 votes
by (47.2k points)
  •  Write this query to get all queries for currently active cursors:

SELECT

    usr.usename                                     AS username

  , min(cur.starttime)                              AS start_time

  , DATEDIFF(second, min(cur.starttime), getdate()) AS run_time

  , min(cur.row_count)                           AS row_count

  , min(cur.fetched_rows)                           AS fetched_rows

  , listagg(util_text.text)

    WITHIN GROUP (ORDER BY sequence)                AS query

FROM STV_ACTIVE_CURSORS cur

  JOIN stl_utilitytext util_text

    ON cur.pid = util_text.pid AND cur.xid = util_text.xid

  JOIN pg_user usr

    ON usr.usesysid = cur.userid

GROUP BY usr.usename, util_text.xid;

  • You can also see the query behind completed cursors by joining STL_QUERY for a fetch query with STL_UTILITYTEXT on pid and xid ordered by sequence. 

Intellipaat offers Tableau Desktop Certification training for the learners to master advanced visualization tools. 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 17, 2019 in BI by Vaibhav Ameta (17.6k points)
0 votes
1 answer
asked Apr 5, 2020 in AWS by Amenda (1.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...