From d519ab580fa42e92778bbb8c40ea525b0bfa4c61 Mon Sep 17 00:00:00 2001 From: Martin Kraft Date: Fri, 16 Oct 2020 10:21:36 -0400 Subject: [PATCH] MM-28815: Message export query optimization. (#15757) * MM-28815: Optimizes message export query. * MM-28815: Removes DeleteAt WHERE condition. * MM-28815: Adds Id to the ORDER BY clause. * MM-28815: Concatenates the string to remove the confusing '%%' in the query. * MM-28115: Remvoes secondary sorting. * MM-28815: Keeps the alias in the order by. * MM-28815: Removing forced index. * MM-28815: Formatting. --- store/sqlstore/compliance_store.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/store/sqlstore/compliance_store.go b/store/sqlstore/compliance_store.go index a5b96f63ca..0e17991ec6 100644 --- a/store/sqlstore/compliance_store.go +++ b/store/sqlstore/compliance_store.go @@ -220,7 +220,6 @@ func (s SqlComplianceStore) MessageExport(after int64, limit int) ([]*model.Mess Posts.Props AS PostProps, Posts.OriginalId AS PostOriginalId, Posts.RootId AS PostRootId, - Posts.Props AS PostProps, Posts.FileIds AS PostFileIds, Teams.Id AS TeamId, Teams.Name AS TeamName, @@ -244,7 +243,7 @@ func (s SqlComplianceStore) MessageExport(after int64, limit int) ([]*model.Mess LEFT OUTER JOIN Users ON Posts.UserId = Users.Id LEFT JOIN Bots ON Bots.UserId = Posts.UserId WHERE - (Posts.CreateAt > :StartTime OR Posts.UpdateAt > :StartTime OR Posts.DeleteAt > :StartTime) AND + Posts.UpdateAt > :StartTime AND Posts.Type NOT LIKE 'system_%' ORDER BY PostUpdateAt LIMIT :Limit`