mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 19:17:32 +00:00
fix: improve performance (#4300)
## Note This release requires a setup step to fully improve performance. Be sure to start ZITADEL with an appropriate command (zitadel start-from-init / start-from-setup) ## Changes - fix: only run projection scheduler on active instances - fix: set default for concurrent instances of projections to 1 (for scheduling) - fix: create more indexes on eventstore.events table - fix: get current sequence for token check (improve reread performance)
This commit is contained in:
@@ -2,6 +2,7 @@ package eventstore
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/database"
|
||||
"github.com/zitadel/zitadel/internal/errors"
|
||||
@@ -30,6 +31,7 @@ type SearchQuery struct {
|
||||
eventSequenceLess uint64
|
||||
eventTypes []EventType
|
||||
eventData map[string]interface{}
|
||||
creationDateAfter time.Time
|
||||
}
|
||||
|
||||
// Columns defines which fields of the event are needed for the query
|
||||
@@ -175,6 +177,12 @@ func (query *SearchQuery) ExcludedInstanceID(instanceIDs ...string) *SearchQuery
|
||||
return query
|
||||
}
|
||||
|
||||
// CreationDateNewer filters for events which happened after the specified time
|
||||
func (query *SearchQuery) CreationDateAfter(time time.Time) *SearchQuery {
|
||||
query.creationDateAfter = time
|
||||
return query
|
||||
}
|
||||
|
||||
// EventTypes filters for events with the given event types
|
||||
func (query *SearchQuery) EventTypes(types ...EventType) *SearchQuery {
|
||||
query.eventTypes = types
|
||||
@@ -234,6 +242,7 @@ func (builder *SearchQueryBuilder) build(instanceID string) (*repository.SearchQ
|
||||
query.eventSequenceLessFilter,
|
||||
query.instanceIDFilter,
|
||||
query.excludedInstanceIDFilter,
|
||||
query.creationDateAfterFilter,
|
||||
query.builder.resourceOwnerFilter,
|
||||
query.builder.instanceIDFilter,
|
||||
} {
|
||||
@@ -344,6 +353,13 @@ func (builder *SearchQueryBuilder) instanceIDFilter() *repository.Filter {
|
||||
return repository.NewFilter(repository.FieldInstanceID, builder.instanceID, repository.OperationEquals)
|
||||
}
|
||||
|
||||
func (query *SearchQuery) creationDateAfterFilter() *repository.Filter {
|
||||
if query.creationDateAfter.IsZero() {
|
||||
return nil
|
||||
}
|
||||
return repository.NewFilter(repository.FieldCreationDate, query.creationDateAfter, repository.OperationGreater)
|
||||
}
|
||||
|
||||
func (query *SearchQuery) eventDataFilter() *repository.Filter {
|
||||
if len(query.eventData) == 0 {
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user