Non-unique primary key index

Learn how Kudu internally creates an auto-incrementing column when you specify columns as non-unique primary key. The specified columns and the auto-incrementing column form the effective primary key. Also learn about the supported and unsupported operations on such tables.

Non-unique primary key columns must be non-nullable, and need not be a boolean, float, or double type.

Once configured during table creation, the set of columns in the non-unique primary key and the auto-incrementing column can not be altered.

Considerations related to operations supported on tables with non-unique primary key are as follows:
  • For insert operations, provide values for the non-unique primary key columns without specifying the values for auto-incrementing column. The auto-incrementing column is populated on the server side automatically.
  • For update or delete operations, provide the complete set of key columns. You need to perform a scan before an update or a delete operation to get the auto-incrementing value.

The non-unique primary key values of a column might not be updated after the row is inserted. However, the row may be deleted and re-inserted with the updated value; moreover, a new auto-incrementing counter value is assigned to the auto-incrementing column during insertion operation.

Operations not supported on tables with non-unique primary key are as follows:

  • Restoring tables with non-unique primary keys is not supported currently.
  • Upsert operation is not supported on tables with non-unique primary key.

For more details on how to use non-unique primary key, see the examples on https://github.com/apache/kudu/tree/master/examples.