From 957d3a7b4dbd4b729174070e6f9cd55d25ca66f0 Mon Sep 17 00:00:00 2001 From: Nicola Murino Date: Sat, 10 Jun 2023 18:23:35 +0200 Subject: [PATCH] CockroachDB: use unordered_unique_rowid for primary keys sequential values in a primary key does not perform as well Signed-off-by: Nicola Murino --- internal/dataprovider/pgsql.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/dataprovider/pgsql.go b/internal/dataprovider/pgsql.go index ac0d68e2..3f7e9966 100644 --- a/internal/dataprovider/pgsql.go +++ b/internal/dataprovider/pgsql.go @@ -786,10 +786,11 @@ func (p *PGSQLProvider) initializeDatabase() error { logger.InfoToConsole("creating initial database schema, version 28") providerLog(logger.LevelInfo, "creating initial database schema, version 28") var initialSQL string - if config.Driver == PGSQLDataProviderName { - initialSQL = sqlReplaceAll(pgsqlInitial + ipListsLikeIndex) - } else { + if config.Driver == CockroachDataProviderName { initialSQL = sqlReplaceAll(pgsqlInitial) + initialSQL = strings.ReplaceAll(initialSQL, "GENERATED ALWAYS AS IDENTITY", "DEFAULT unordered_unique_rowid()") + } else { + initialSQL = sqlReplaceAll(pgsqlInitial + ipListsLikeIndex) } return sqlCommonExecSQLAndUpdateDBVersion(p.dbHandle, []string{initialSQL}, 28, true)