Clustering a partitioned 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.
To add a clustered column to a persistent derived table (PDT) or an aggregate table, use the cluster_keys parameter and supply the names of the columns you want clustered in the database table.
Examples
Create a customer_order_factsnative derived table 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:
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:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["# cluster_keys\n\n\u003cbr /\u003e\n\nUsage\n-----\n\n```\nview: view_name {\n derived_table: {\n cluster_keys: [\"customer_city\", \"customer_state\"]\n ...\n }\n}\n```\n\nDefinition\n----------\n\nClustering a [partitioned](/looker/docs/2512/reference/param-view-partition-keys) 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.\n\nSee the [Dialect support for `cluster_keys`](#dialect_support) section for the list of dialects that support `cluster_keys`.\n\n| **Notes:**\n|\n| - The `cluster_keys` parameter works only with tables that are [persistent](/looker/docs/2512/derived-tables#adding_persistence), such as PDTs and aggregate tables. `cluster_keys` is not supported for [derived tables](/looker/docs/2512/creating-ndts) without a persistence strategy.\n| - In addition, the `cluster_keys` parameter is not supported for derived tables that are defined using [`create_process`](/looker/docs/2512/reference/param-view-create-process) or [`sql_create`](/looker/docs/2512/reference/param-view-sql-create).\n\nTo add a clustered column to a [persistent derived table](/looker/docs/2512/derived-tables#persistent-derived-tables) (PDT) or an [aggregate table](/looker/docs/2512/reference/param-explore-aggregate-table), use the `cluster_keys` parameter and supply the names of the columns you want clustered in the database table.\n\nExamples\n--------\n\nCreate a `customer_order_facts` [native derived table](/looker/docs/2512/creating-ndts) 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: \n\n view: customer_order_facts {\n derived_table: {\n explore_source: order {\n column: customer_id { field: order.customer_id }\n column: date { field: order.order_time }\n column: city { field: users.city}\n column: age_tier { field: users.age_tier }\n column: gender { field: users.gender }\n derived_column: num_orders {\n sql: COUNT(order.customer_id) ;;\n }\n }\n partition_keys: [ \"date\" ]\n cluster_keys: [ \"city\", \"age_tier\", \"gender\" ]\n datagroup_trigger: daily_datagroup\n }\n }\n\nDialect support for `cluster_keys`\n----------------------------------\n\nThe 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`:"]]