<br />

## Usage

```
view: view_name {
  derived_table: {
    cluster_keys: ["customer_city", "customer_state"]
    ...
  }
}
```

|---|---|
| Hierarchy [View File](https://docs.cloud.google.com/looker/docs/reference/param-view.md.txt) [`view`](https://docs.cloud.google.com/looker/docs/reference/param-view-view.md.txt) [`derived_table`](https://docs.cloud.google.com/looker/docs/reference/param-view-derived-table.md.txt) `cluster_keys` - or - [Model File](https://docs.cloud.google.com/looker/docs/reference/param-model.md.txt) [`explore`](https://docs.cloud.google.com/looker/docs/reference/param-explore-explore.md.txt) [`aggregate_table`](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt) [`materialization`](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt#materialization) `cluster_keys` | Default Value `None` <br /> Accepts One or more clustered column names <br /> Special Rules `cluster_keys` is supported only on [specific dialects](https://docs.cloud.google.com/looker/docs/reference/param-view-cluster-keys.md.txt#dialect_support) |

## Definition

Clustering a [partitioned](https://docs.cloud.google.com/looker/docs/reference/param-view-partition-keys.md.txt) table sorts the data in a partition based on the values in the clustered columns and organizes the clustered columns in optimally sized storage blocks. Clustering can improve the performance and reduce the cost of queries that filter on or aggregate by the clustered columns.

See the [Dialect support for `cluster_keys`](https://docs.cloud.google.com/looker/docs/reference/param-view-cluster-keys.md.txt#dialect_support) section for the list of dialects that support `cluster_keys`.

> [!NOTE]
> **Notes:**
>
> - The `cluster_keys` parameter works only with tables that are [persistent](https://docs.cloud.google.com/looker/docs/derived-tables.md.txt#adding_persistence), such as PDTs and aggregate tables. `cluster_keys` is not supported for [derived tables](https://docs.cloud.google.com/looker/docs/creating-ndts.md.txt) without a persistence strategy.
> - In addition, the `cluster_keys` parameter is not supported for derived tables that are defined using [`create_process`](https://docs.cloud.google.com/looker/docs/reference/param-view-create-process.md.txt) or [`sql_create`](https://docs.cloud.google.com/looker/docs/reference/param-view-sql-create.md.txt).

To add a clustered column to a [persistent derived table](https://docs.cloud.google.com/looker/docs/derived-tables.md.txt#persistent-derived-tables) (PDT) or an [aggregate table](https://docs.cloud.google.com/looker/docs/reference/param-explore-aggregate-table.md.txt), use the `cluster_keys` parameter and supply the names of the columns you want clustered in the database table.

## Examples

Create a `customer_order_facts` [native derived table](https://docs.cloud.google.com/looker/docs/creating-ndts.md.txt) on a BigQuery database, partitioned on the `date` column and clustered on the `city`, `age_tier`, and `gender` columns to optimize queries that are filtered or aggregated on those columns:

    view: customer_order_facts {
      derived_table: {
        explore_source: order {
          column: customer_id { field: order.customer_id }
          column: date { field: order.order_time }
          column: city { field: users.city}
          column: age_tier { field: users.age_tier }
          column: gender { field: users.gender }
          derived_column: num_orders {
            sql: COUNT(order.customer_id) ;;
          }
        }
        partition_keys: [ "date" ]
        cluster_keys: [ "city", "age_tier", "gender" ]
        datagroup_trigger: daily_datagroup
      }
    }

## Dialect support for `cluster_keys`

The ability to use `cluster_keys` depends on the database dialect your Looker connection is using. In the latest release of Looker, the following dialects support `cluster_keys`:

| Dialect | Supported? |
|---|---|
| Actian Avalanche | No |
| Amazon Athena | No |
| Amazon Aurora MySQL | No |
| Amazon Redshift | No |
| Amazon Redshift 2.1+ | No |
| Amazon Redshift Serverless 2.1+ | No |
| Apache Druid | No |
| Apache Druid 0.13.x - 0.17.x | No |
| Apache Druid 0.18+ | No |
| Apache Hive 2.3+ | No |
| Apache Hive 3.1.2+ | No |
| Apache Spark 3+ | No |
| ClickHouse | No |
| ClickHouse 26+ | No |
| Cloudera Impala 3.1+ | No |
| Cloudera Impala 3.1+ with Native Driver | No |
| Cloudera Impala with Native Driver | No |
| DataVirtuality | No |
| Databricks | No |
| Denodo 7 | No |
| Denodo 8 \& 9 | No |
| Dremio | No |
| Dremio 11+ | No |
| Dremio 26+ with Arrow Flight SQL | No |
| Exasol | No |
| Google BigQuery Legacy SQL | Yes |
| Google BigQuery Standard SQL | Yes |
| Google Cloud AlloyDB for PostgreSQL | No |
| Google Cloud PostgreSQL | No |
| Google Cloud SQL | No |
| Google Spanner | No |
| Greenplum | No |
| HyperSQL | No |
| IBM Netezza | No |
| MariaDB | No |
| Microsoft Azure PostgreSQL | No |
| Microsoft Azure SQL Database | No |
| Microsoft Azure Synapse Analytics | No |
| Microsoft SQL Server 2008+ | No |
| Microsoft SQL Server 2012+ | No |
| Microsoft SQL Server 2016 | No |
| Microsoft SQL Server 2017+ | No |
| MongoBI | No |
| MongoSQL | No |
| MySQL | No |
| MySQL 8.0.12+ | No |
| Oracle | No |
| Oracle ADWC | No |
| PostgreSQL 9.5+ | No |
| PostgreSQL pre-9.5 | No |
| PrestoDB | No |
| PrestoSQL | No |
| SAP HANA | No |
| SAP HANA 2+ | No |
| SingleStore | No |
| SingleStore 7+ | No |
| Snowflake | Yes |
| Teradata | No |
| Trino | No |
| Vector | No |
| Vertica | No |