sortkeys is a child of
derived_table is a child of
one or more columns from
the derived table sql
sortkeys enables you to specify one or more columns of a persistent derived table on which to apply a regular sort key. Currently,
sortkeys only works with Redshift databases. You can also create an interleaved sort key by using
indexes instead. You cannot use both at the same time, but at least one is required.
Traditional SQL dialects (such as MySQL and Postgres) should use
sortkeys will not work with these databases.
Generally speaking, a sort key should be applied to date or time columns in the derived table, and possibly to columns that will be used frequently as filters. More information can be found in the Amazon Redshift documentation.
Create a customer_day_facts derived table with a sortkey on date:
Create a customer_day_facts derived table with a sortkey on date and customer_id: