Search code examples
postgresqldebezium

Does Debezium use Postgres primary key for partition key?


I was looking at Debezium documentation: https://debezium.io/documentation/reference/configuration/topic-routing.html

I can only see how to specify custom keys, but I cannot understand if by default it is using the DB primary key as routing key.

The DB primary key could even be a triplet like (column1, column2. column3)


Solution

  • Yes, it is possible by using message.key.columns

    Sample:

    {
      "name": "my-connector",
      "config": {
        "...": "...",
        "message.key.columns": "my_database.users:department_id"
      }
    }
    

    Documentation: https://debezium.io/documentation/reference/connectors/postgresql.html#postgresql-property-message-key-columns.