Skip to content

Commit

Permalink
Merge branch 'Tochemey:main' into upsert-data-in-postgres-statestore
Browse files Browse the repository at this point in the history
  • Loading branch information
sdil authored Dec 17, 2024
2 parents 2df5257 + c7cf58d commit 5a72ced
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
8 changes: 0 additions & 8 deletions plugins/statestore/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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),
}
}
Expand Down
2 changes: 2 additions & 0 deletions resources/durablestore_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5a72ced

Please sign in to comment.