yugabytedb

How to create range partioned, date partitioned, geo partioned tables in yugabyte-db?


It is understood that yugabyte creates hash partitioned tables by default.

Please guide me in creating range partioned, date partitioned, geo partioned tables in yugabyte-db with multiple tablets.


Solution

  • Hash partitioned table is specified as CREATE TABLE sample(k1 int, k2 int, PRIMARY KEY (k1, k2));

    Setting the first column of the primary key as ASC/DESC will use range partitioning like:

    CREATE TABLE sample(k1 int, k2 int, PRIMARY KEY (k1 ASC, k2 DESC));

    Docs page for more info: https://docs.yugabyte.com/latest/api/ysql/commands/ddl_create_table/

    Geo partitioned tables are not yet possible. You can subscribe to this issue: https://github.com/yugabyte/yugabyte-db/issues/1958