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

# custom_primary_key_sql_for_quick_aggs - Dimensions

> Defines a custom primary key for aggregate measures where a primary key is applicable.

This is useful for ensuring that [symmetric aggregates](https://docs.omni.co/analyze-explore/sql/symmetric-aggregates.md) are computed correctly. This is useful for BigQuery [nested columns (`structs`)](https://docs.omni.co/analyze-explore/sql/symmetric-aggregates#handling-fan-out-from-unnested-columns) and Postgres columns that are [arrays of a composite type](https://www.postgresql.org/docs/current/extend-type-system.html).

## Syntax

```yaml theme={null}
<dimension_name>:
  custom_primary_key_sql_for_quick_aggs: ${<field_reference>}
```

## Properties

**dimension\_name** `object`

The name of the dimension. Dimension names must:

* Be unique within the view
* Start with a letter
* Contain only alphanumeric characters and underscores

**dimension\_name properties**

**custom\_primary\_key\_sql\_for\_quick\_aggs** `string`

A field reference specifying the custom primary key to use for quick aggregate calculations.

## Examples

```yaml title="Nested column with custom primary key" theme={null}
dimensions:
  order_id:
    primary_key: true
  order_items: {}
  order_item_price:
    parent_field: order_items
    nested_on_field: order_items
    custom_primary_key_sql_for_quick_aggs: ${order_item_id}
    sql: price

measures:
  total_price:
    sql: ${order_item_price}
    aggregate_type: sum_distinct_on
    custom_primary_key_sql: ${order_item_id}
```
