fix: improve performance by reducing full table scans (#4684)

* use instance id on update in projections

* create index on domain in instance_domain projection

* add missing instanceID filter to app queries
This commit is contained in:
Livio Spring
2022-11-10 11:59:33 +01:00
committed by GitHub
parent ac66a54df9
commit 78ae64471a
71 changed files with 683 additions and 399 deletions

View File

@@ -23,7 +23,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
want wantReduce
}{
{
name: "org.reduceAdded",
name: "org reduceAdded",
args: args{
event: getEvent(testEvent(
repository.EventType(org.PasswordAgePolicyAddedEventType),
@@ -61,7 +61,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
},
},
{
name: "org.reduceChanged",
name: "org reduceChanged",
reduce: (&passwordAgeProjection{}).reduceChanged,
args: args{
event: getEvent(testEvent(
@@ -80,13 +80,14 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5)",
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
uint64(10),
uint64(13),
"agg-id",
"instance-id",
},
},
},
@@ -94,7 +95,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
},
},
{
name: "org.reduceRemoved",
name: "org reduceRemoved",
reduce: (&passwordAgeProjection{}).reduceRemoved,
args: args{
event: getEvent(testEvent(
@@ -110,9 +111,10 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "DELETE FROM projections.password_age_policies WHERE (id = $1)",
expectedStmt: "DELETE FROM projections.password_age_policies WHERE (id = $1) AND (instance_id = $2)",
expectedArgs: []interface{}{
"agg-id",
"instance-id",
},
},
},
@@ -120,7 +122,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceInstanceRemoved",
name: "instance reduceInstanceRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceRemovedEventType),
@@ -146,7 +148,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceAdded",
name: "instance reduceAdded",
reduce: (&passwordAgeProjection{}).reduceAdded,
args: args{
event: getEvent(testEvent(
@@ -184,7 +186,7 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceChanged",
name: "instance reduceChanged",
reduce: (&passwordAgeProjection{}).reduceChanged,
args: args{
event: getEvent(testEvent(
@@ -203,13 +205,14 @@ func TestPasswordAgeProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5)",
expectedStmt: "UPDATE projections.password_age_policies SET (change_date, sequence, expire_warn_days, max_age_days) = ($1, $2, $3, $4) WHERE (id = $5) AND (instance_id = $6)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
uint64(10),
uint64(13),
"agg-id",
"instance-id",
},
},
},