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 TestMailTemplateProjection_reduces(t *testing.T) {
want wantReduce
}{
{
name: "org.reduceAdded",
name: "org reduceAdded",
args: args{
event: getEvent(testEvent(
repository.EventType(org.MailTemplateAddedEventType),
@@ -58,7 +58,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
},
},
{
name: "org.reduceChanged",
name: "org reduceChanged",
reduce: (&mailTemplateProjection{}).reduceChanged,
args: args{
event: getEvent(testEvent(
@@ -76,12 +76,13 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4)",
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
[]byte("<table></table>"),
"agg-id",
"instance-id",
},
},
},
@@ -89,7 +90,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
},
},
{
name: "org.reduceRemoved",
name: "org reduceRemoved",
reduce: (&mailTemplateProjection{}).reduceRemoved,
args: args{
event: getEvent(testEvent(
@@ -105,9 +106,10 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "DELETE FROM projections.mail_templates WHERE (aggregate_id = $1)",
expectedStmt: "DELETE FROM projections.mail_templates WHERE (aggregate_id = $1) AND (instance_id = $2)",
expectedArgs: []interface{}{
"agg-id",
"instance-id",
},
},
},
@@ -115,7 +117,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceInstanceRemoved",
name: "instance reduceInstanceRemoved",
args: args{
event: getEvent(testEvent(
repository.EventType(instance.InstanceRemovedEventType),
@@ -141,7 +143,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceAdded",
name: "instance reduceAdded",
reduce: (&mailTemplateProjection{}).reduceAdded,
args: args{
event: getEvent(testEvent(
@@ -176,7 +178,7 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
},
},
{
name: "instance.reduceChanged",
name: "instance reduceChanged",
reduce: (&mailTemplateProjection{}).reduceChanged,
args: args{
event: getEvent(testEvent(
@@ -194,12 +196,13 @@ func TestMailTemplateProjection_reduces(t *testing.T) {
executer: &testExecuter{
executions: []execution{
{
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4)",
expectedStmt: "UPDATE projections.mail_templates SET (change_date, sequence, template) = ($1, $2, $3) WHERE (aggregate_id = $4) AND (instance_id = $5)",
expectedArgs: []interface{}{
anyArg{},
uint64(15),
[]byte("<table></table>"),
"agg-id",
"instance-id",
},
},
},