diff --git a/plugins/statestore/postgres/postgres.go b/plugins/statestore/postgres/postgres.go index f4c7748..1c8a51b 100644 --- a/plugins/statestore/postgres/postgres.go +++ b/plugins/statestore/postgres/postgres.go @@ -57,13 +57,6 @@ var ( type DurableStore struct { db postgres.Postgres sb sq.StatementBuilderType - // insertBatchSize represents the chunk of data to bulk insert. - // This helps avoid the postgres 65535 parameter limit. - // This is necessary because Postgres uses a 32-bit int for binding input parameters and - // is not able to track anything larger. - // Note: Change this value when you know the size of data to bulk insert at once. Otherwise, you - // might encounter the postgres 65535 parameter limit error. - insertBatchSize int // hold the connection state to avoid multiple connection of the same instance connected *atomic.Bool } @@ -78,7 +71,6 @@ func NewStateStore(config *Config) *DurableStore { return &DurableStore{ db: db, sb: sq.StatementBuilder.PlaceholderFormat(sq.Dollar), - insertBatchSize: 500, connected: atomic.NewBool(false), } } diff --git a/resources/durablestore_postgres.sql b/resources/durablestore_postgres.sql index d7da67b..a2c5993 100644 --- a/resources/durablestore_postgres.sql +++ b/resources/durablestore_postgres.sql @@ -32,6 +32,8 @@ CREATE TABLE IF NOT EXISTS states_store shard_number BIGINT NOT NULL, PRIMARY KEY (persistence_id, version_number) + CREATE INDEX IF NOT EXISTS idx_states_store_persistence_id ON events_store(persistence_id); + CREATE INDEX IF NOT EXISTS idx_states_store_version_number ON events_store(version_number); ); CREATE INDEX IF NOT EXISTS idx_states_store_persistence_id ON states_store(persistence_id);