From 8b17bf9e42dd56ecd0fe8300da90bea5ee8684ef Mon Sep 17 00:00:00 2001 From: Jesse Hallam Date: Thu, 13 Sep 2018 13:47:17 -0400 Subject: MM-11886: materialize channel search (#9349) * materialize PublicChannels table Introduce triggers for each supported database that automatically maintain a subset of the Channels table corresponding to only public channels. This improves corresponding queries that no longer need to filter out 99% DM channels. This initial commit modifies the channel store directly for easier code reviewing, but the next wraps an experimental version around it to enable a kill switch in case there are unforeseen performance regressions. This addresses [MM-11886](https://mattermost.atlassian.net/browse/MM-11886) and [MM-11945](https://mattermost.atlassian.net/browse/MM-11945). * extract the experimental public channels materialization Wrap the original channel store with an experimental version that leverages the materialized public channels, but can be disabled to fallback to the original implementation. This addresses MM-11947. * s/ExperimentalPublicChannelsMaterialization/EnablePublicChannelsMaterialization/ * simplify error handling * move experimental config listener until after store is initialized --- app/app.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/app.go') diff --git a/app/app.go b/app/app.go index c3fcc7aec..511a464be 100644 --- a/app/app.go +++ b/app/app.go @@ -212,6 +212,14 @@ func New(options ...Option) (outApp *App, outErr error) { } app.Srv.Store = app.newStore() + app.AddConfigListener(func(_, current *model.Config) { + if current.SqlSettings.EnablePublicChannelsMaterialization != nil && !*current.SqlSettings.EnablePublicChannelsMaterialization { + app.Srv.Store.Channel().DisableExperimentalPublicChannelsMaterialization() + } else { + app.Srv.Store.Channel().EnableExperimentalPublicChannelsMaterialization() + } + }) + if err := app.ensureAsymmetricSigningKey(); err != nil { return nil, errors.Wrapf(err, "unable to ensure asymmetric signing key") } -- cgit v1.2.3-1-g7c22