Usage
derived_table: {
indexes: ["order_id"]
…
}
}
Hierarchyindexes - or - indexes |
Default ValueNoneAcceptsThe names of one or more columns in a PDT or an aggregate tableSpecial Rulesindexes is supported only on specific dialects
|
Definition
The indexes
parameter lets you apply indexes to the columns of a persistent derived table (PDT) or an aggregate table. When you add more than one column, Looker will create one index for each column that you specify; it does not create a single, multi-column index. If the indexes
parameter is missing from the query, Looker will warn you to add an indexes
parameter to improve query performance. Learn more about indexing persistent derived tables on the Derived tables in Looker documentation page.
See the Dialect support for
indexes
section on this page for the list of dialects that supportindexes
.The
indexes
parameter works only with tables that are persistent, such as PDTs and aggregate tables.indexes
is not supported for derived tables without a persistence strategy.In addition, the
indexes
parameter is not supported for derived tables that are defined usingcreate_process
orsql_create
.
If you use indexes
with Redshift, you will create an interleaved sort key. You can also create regular sort keys using sortkeys
, but you cannot use both at the same time. Distribution keys can be created with distribution
.
Generally speaking, indexes should be applied to primary keys and date or time columns.
Examples
For a traditional database (for example, MySQL or Postgres), create a customer_order_facts
persistent derived table. The PDT should rebuild when the order_datagroup
datagroup is triggered and will have an index on customer_id
:
For a traditional database, create a customer_order_facts
persistent derived table that is based on a SQL query and applies an index on customer_id
:
For a traditional database, create a customer_day_facts
derived table with indexes on both customer_id
and date
:
For a Redshift database, create a customer_day_facts
derived table with an interleaved sort key built from customer_id
and date
:
Dialect support for indexes
The ability to use indexes
depends on the database dialect your Looker connection is using. If you are working with something other than a traditional database (for example, MySQL or Postgres), your database may not support the indexes
parameter. Looker will warn you if this is the case. You can swap out the indexes
parameter for one that is appropriate for your database connection. Learn more about such parameters on the View parameters documentation page.
In Looker 22.6, the following dialects support indexes
: