The result: a significant reduction in query costs and execution time.
- Click on the Integrations link in the sidebar of superQuery:
- Enable your desired connection by clicking “Connect”
- After clicking “Connect” you’ll see the username and password screen, like so:
- Whitelist your IP Address if necessary
- Copy the hostname and port from this window into your service of choice.
- server: proxy.superquery.io
- port: 3306
6. Finalize the connection.
- Download RStudio
- In RStudio run the following from the console:
Connect RStudio to superQuery
- Open RStudio and create a new R script:
mydb = dbConnect(MySQL(), user='xxxx', password='xxxx', dbname='yourproject.yourdataset', host='proxy.superquery.io')
rs = dbSendQuery(mydb, 'SELECT COUNT(*) FROM `yourproject.yourdataset.yourtable`;')
data = fetch(rs, n=-1)
rs_explain = dbSendQuery(mydb, 'explain;')
data_explain = fetch(rs_explain, n=-1)
data_explain = fromJSON(data_explain$statistics)
- Enter the following details into the script:
- Your username and password into the ‘xxxx’ parts
- yourproject, yourdataset and yourtable in the relevants parts.
- Run the script and you will see two variables were created:
The variable called “data” will contain your query results and the variable “data_explain” will contain your query’s execution plan and statistics. It should look like this:
Boom! You’re all set.
Now you can start building your own beautiful dashboards.
Query on! 🙂