---
title: "How to query sharded tables"
slug: "how-to-query-sharded-tables"
description: "Learn how to optimize BigQuery data transfers to Tableau and PowerBI, query sharded tables, and enhance performance with effective SQL techniques."
updated: 2026-06-04T10:16:37Z
published: 2026-06-04T10:16:37Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.supermetrics.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to query sharded tables

When Supermetrics transfers data from BigQuery, [it creates sharded tables](/v1/docs/about-sharded-tables-in-bigquery-marketplace). Follow these instructions to select and query data from a single table shard (one day of data), optimize your queries, and prepare the data for transfer to Tableau or Power BI.

## Instructions

****Query a sharded table****

Running this query in [the Google Cloud Console](https://cloud.google.com/bigquery/docs/bigquery-web-ui#overview) will select data from a single table shard:

`select *`

`from `project.dataset.datasource_tablename_20220101``

To query all the data that exists in a set of sharded tables, however, you need to ensure that BigQuery combines the data from all of these tables together [using a wildcard](https://cloud.google.com/bigquery/docs/querying-wildcard-tables).

The following query uses a star (*) as the wildcard. This instructs BigQuery to “query data from all tables that match this naming convention”:

`select *`

`from `project.dataset.datasource_tablename_*``

****Prepare data for Tableau or Power BI****

While Data Studio (formerly Looker Studio) natively reads sharded tables, most BI tools don’t. This means that if you try to connect Tableau or Power BI directly to your sharded tables, they’ll reach them as hundreds of individual tables that aren’t connected to each other.

Creating [a BigQuery view](https://cloud.google.com/bigquery/docs/views) that uses a wildcard before loading the data into a BI tool solves this problem. A view combines the results of the underlying sharded tables into a single object that both Tableau and Power BI can access.

**Instructions**

Enter this query in the [Google Cloud Console](https://cloud.google.com/bigquery/docs/bigquery-web-ui#overview):

`select *`

`from `project.dataset.datasource_tablename_*``

After it’s run, you’ll see a **SAVE** button that allows you to **Save view**. Select this, name the new view, and then choose which dataset it’ll live in.

If you’d prefer to do this using SQL syntax, you can run the following command instead:

`create or replace view dataset.viewname`

`as `

`select *`

`from `project.dataset.datasource_tablename_*``

****Optimize queries****

Creating a view (“Prepare data for Tableau or Power BI” above) allows you to select all data in a sharded table set. In some cases, however, you might not need all of that data in every query.

Sharded tables have some useful properties that can improve each query’s speed and reduce its cost while offering precise control over the data they pull.

Both of the techniques below enable BigQuery to determine exactly which tables need to be scanned before it executes the query. These deeply reduced scan sizes improve the speed and costs of the associated queries.

**Move the wildcard**

The easiest way to specify your selection of data is to move the query’s wildcard to a different position.

For example, this query will select data from only January 2022:

`select *`

`from `project.dataset.datasource_tablename_202201*``

With the wildcard just after the month value, the query now returns data for only a single month. By extension, this query will return all data from all of 2022:

`select *`

`from `project.dataset.datasource_tablename_2022*``

**Use the _TABLE_SUFFIX**

A dynamically defined time range can make a query even more efficient.

For example, this query will return all data after January 2022:

`select *`

`from `project.dataset.datasource_tablename_*``

`where _TABLE_SUFFIX &gt; ‘20220131’`

In this case, adding [_TABLE_SUFFIX](https://cloud.google.com/bigquery/docs/querying-wildcard-tables#filtering_selected_tables_using_table_suffix) to the WHERE clause limits the amount of data being returned by the query.

****Delete sharded tables****

The process for deleting sharded tables is delicate. If carried out incorrectly, it could result in the deletion of data in unintended locations.

[Learn how to delete sharded tables in our guide](/v1/docs/how-to-delete-multiple-bigquery-tables).

## More resources

- [About BigQuery sharded tables](/v1/docs/about-sharded-tables-in-bigquery-marketplace)
