mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
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:
@@ -22,7 +22,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
want wantReduce
|
||||
}{
|
||||
{
|
||||
name: "org.reduceSet",
|
||||
name: "org reduceSet",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(org.CustomTextSetEventType),
|
||||
@@ -62,7 +62,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceRemoved",
|
||||
name: "org reduceRemoved",
|
||||
reduce: (&customTextProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@@ -82,12 +82,13 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"Text",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -95,7 +96,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "org.reduceTemplateRemoved",
|
||||
name: "org reduceTemplateRemoved",
|
||||
reduce: (&customTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@@ -115,11 +116,12 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -127,7 +129,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "instance.reduceInstanceRemoved",
|
||||
name: "instance reduceInstanceRemoved",
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
repository.EventType(instance.InstanceRemovedEventType),
|
||||
@@ -153,7 +155,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceAdded",
|
||||
name: "instance reduceAdded",
|
||||
reduce: (&customTextProjection{}).reduceSet,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@@ -193,7 +195,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceRemoved",
|
||||
name: "instance reduceRemoved",
|
||||
reduce: (&customTextProjection{}).reduceRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@@ -213,12 +215,13 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (key = $3) AND (language = $4) AND (instance_id = $5)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"Text",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -226,7 +229,7 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iam.reduceTemplateRemoved",
|
||||
name: "instance reduceTemplateRemoved",
|
||||
reduce: (&customTextProjection{}).reduceTemplateRemoved,
|
||||
args: args{
|
||||
event: getEvent(testEvent(
|
||||
@@ -246,11 +249,12 @@ func TestCustomTextProjection_reduces(t *testing.T) {
|
||||
executer: &testExecuter{
|
||||
executions: []execution{
|
||||
{
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3)",
|
||||
expectedStmt: "DELETE FROM projections.custom_texts WHERE (aggregate_id = $1) AND (template = $2) AND (language = $3) AND (instance_id = $4)",
|
||||
expectedArgs: []interface{}{
|
||||
"agg-id",
|
||||
"InitCode",
|
||||
"en",
|
||||
"instance-id",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Reference in New Issue
Block a user