mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 14:17:17 +00:00
fix: improve performance on db insert (#1649)
This commit is contained in:
parent
9d778fa67c
commit
06281b5ccb
@ -37,10 +37,9 @@ const (
|
||||
//previous_data selects the needed data of the latest event of the aggregate
|
||||
// and buffers it (crdb inmemory)
|
||||
" WITH previous_data AS (" +
|
||||
" SELECT MAX(event_sequence) AS seq, resource_owner " +
|
||||
" SELECT event_sequence AS seq, resource_owner " +
|
||||
" FROM eventstore.events " +
|
||||
//TODO: remove LIMIT 1 / order by as soon as data cleaned up (only 1 resource_owner per aggregate)
|
||||
" WHERE aggregate_type = $2 AND aggregate_id = $3 GROUP BY resource_owner order by seq desc LIMIT 1" +
|
||||
" WHERE aggregate_type = $2 AND aggregate_id = $3 ORDER BY seq DESC LIMIT 1" +
|
||||
" )" +
|
||||
// defines the data to be inserted
|
||||
" SELECT " +
|
||||
|
2
migrations/cockroach/V1.41__index_max_seq.sql
Normal file
2
migrations/cockroach/V1.41__index_max_seq.sql
Normal file
@ -0,0 +1,2 @@
|
||||
use eventstore;
|
||||
CREATE INDEX IF NOT EXISTS max_sequence on eventstore.events (aggregate_type, aggregate_id, event_sequence DESC);
|
Loading…
x
Reference in New Issue
Block a user