.alter table row order policy

Change a table's row order policy. The row order policy is an optional table policy that defines the row order in a data shard. This policy can improve performance for queries that relate to a small set of values that can be ordered.

Syntax

.alter table TableName policy roworder PolicyObject

Arguments

  • TableName - Specify the name of the table.
  • PolicyObject - Define a policy object, see also row order policy.

Examples

Set the row order policy for one table:

.alter table events policy roworder (TenantId asc, Timestamp desc)

Set the row order policy for several tables:

.alter tables (events1, events2, events3) policy roworder (TenantId asc, Timestamp desc)

The following example sets the row order policy on the TenantId column (ascending) as a primary key, and on the Timestamp column (ascending) as the secondary key. The policy is then queried.

.alter table events policy roworder (TenantId asc, Timestamp desc)

.alter tables (events1, events2, events3) policy roworder (TenantId asc, Timestamp desc)

.show table events policy roworder 
TableName RowOrderPolicy
events (TenantId asc, Timestamp desc)