ThoughtSpot acquires Mode to define the next generation of collaborative BI >>Learn More

Additional Resources

template

Defining Metrics: A Template 
for Working With Stakeholders

Guide

10 Things Modern Business 
Intelligence Should Enable Today

video

Watch a Product Tour of Mode

Get started with Mode

Better Admin Controls with Query Headers

Image of author
Angeline Char, Product Marketing

September 28, 2017

2 minute read

email-query-headers-@2x

Earlier this week, we released visualization filters that allow everyone on Mode to interact more deeply with dashboards to find new answers.

Today, we're looking at you, admins. With the launch of Query Headers, you can now prepend queries with template statements that execute with every query run. Query Headers make administrative management more efficient and customizable to fit the needs of your organization.

Query Headers let you better manage query queues, improve query performance, and have more visibility into how Mode interacts with your database. With the option to prepend queries to take specific actions, Query Headers allow you to:

  • Set priority queues for specified users such as high-frequency query authors.
  • Control database load by dynamically assigning different queries to different queues.
  • Automatically set environmental variables such as default schemas, timezones, and more.

How do Query Headers work?

Under Settings > Connections, you'll find a page for each data connection. This is where you can write SQL to prepend every query run through the connection.

Set up a Query Header

Did you know: You can create multiple connections to the same database and limit query access to specific connections based on database user roles. Mode customers use this to allow certain teams access to a more complete view of a database (say, sensitive tables like compensation or financial details).

A connection that contains a Query Header will prepend the SQL before every query run against that database. Using parameters, you can make the Query Header dynamic. In this case, the Query Header will vary depending on who runs the query, whether or not the query is scheduled, or many other variables.

Use these five parameters to make your Query Headers dynamic:

Parameter What it is
query_runnner_email Email address of user running the query
query_runner_username Username of user running the query
query_runnner_groups An array of group tokens that the user is a member of
run_at Unix timestamp of when the query was run
is_scheduled Boolean for if the query is scheduled

Example Query Headers

Assign scheduled queries to different query groups in Redshift:

{% if is_scheduled == true }
  SET query_group TO scheduled_queries;
{% endif % }

Set a default schema:

SET SEARCH_PATH TO 'webapp';

Add custom logging to queries:

-- Run by {{ query_runner_email }}
-- Run at {{ run_at }}
{% if is_scheduled == true %}
-- Scheduled run
{% else %}
-- Manual run
{% endif %}

Here's what your query history could look like with the last example included:

View a Query Header in your query history

There's More

We're building more and more into Mode to help analysts, teams, and organizations collaborate around data. Next week, we'll be making Mode a little more colorful—stay tuned!

For more information on how to set up Query Headers, check out our help site documentation. Or, sign in to get started.

Have questions or feedback? Email us at hi@modeanalytics.com, or reach out to us by opening a chat right in the product. We love hearing from you!

Get our weekly data newsletter

Work-related distractions for data enthusiasts.

Additional Resources

template

Defining Metrics: A Template 
for Working With Stakeholders

Guide

10 Things Modern Business 
Intelligence Should Enable Today

video

Watch a Product Tour of Mode

Get started with Mode