Agniva De Sarker d938d70dcd MM-21211: Optimize Channelstore.UpdateLastViewedAt (#13529)
* MM-21211: Optimize Channelstore.UpdateLastViewedAt

For postgres, we use CTEs to do both queries at one
and return the data.

For mysql, CTEs aren't available until version 8. So we just optimize the
existing query.

- We use IN instead of multiple OR conditions for the channel membership check.
According to mysql https://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_in:

If no type conversion is needed for the values in the IN() list,
they are all constants of the same type, and expr can be compared to each of them
as a value of the same type (possibly after type conversion), an optimization takes place.

The values the list are sorted and the search for expr is done using a binary search,
which makes the IN() operation very quick.

- We use the previous column LastViewedAt to replace the value of LastUpdateAt
instead of doing a switch case again.

https://dev.mysql.com/doc/refman/5.6/en/ansi-diff-update.html

If you access a column from the table to be updated in an expression, UPDATE uses the
current value of the column.

Results (ran with getchannel profile):

Postgres:
| Metric | Baseline | Actual | Delta | Delta % |
| --- | --- | --- | --- | --- |
| Hits | 1594 | 1574 | -20 | -1.25%
| Error Rate | 0.00% | 0.00% | 0% | 0% |
| Mean Response Time | 7.08ms | 6.36ms | -0.72ms | -10.20% |
| Median Response Time | 5.00ms | 4.00ms | -1.00ms | -20.00% |
| 95th Percentile | 9.00ms | 8.00ms | -1.00ms | -11.11% |

Mysql:
| Metric | Baseline | Actual | Delta | Delta % |
| --- | --- | --- | --- | --- |
| Hits | 1600 | 1566 | -34 | -2.12%
| Error Rate | 0.00% | 0.00% | 0% | 0% |
| Mean Response Time | 7.39ms | 7.02ms | -0.37ms | -4.94% |
| Median Response Time | 6.00ms | 6.00ms | 0ms | 0% |
| 95th Percentile | 10.00ms | 10.00ms | 0ms | 0% |

* Add comment on using CTEs for mysql8

* incorporate review comments

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-09 22:04:30 +05:30
2020-01-06 11:17:19 -08:00
2019-04-04 09:49:07 -04:00
2020-01-07 17:00:56 +01:00
2018-05-30 10:23:25 -04:00
2019-10-29 15:05:54 +00:00
2019-03-27 14:05:34 +01:00
2019-05-01 16:33:07 +02:00

Mattermost

Mattermost is an open source, private cloud, Slack-alternative from https://mattermost.com.

It's written in Golang and React and runs as a single Linux binary with MySQL or PostgreSQL. Every month on the 16th a new compiled version is released under an MIT license.

screenshot at nov 29 14-11-32

Try out Mattermost

Deploy on Heroku

Deploy a Preview

Note: Heroku preview does not include email or persistent storage

Deploy on a Cloud Platform via Bitnami

Auto-deploy Mattermost to Amazon Web Services, Azure, Google Cloud Platform, or Oracle Cloud Platform via Bitnami.

Install on Your Own Machine

Native Mobile and Desktop Apps

In addition to the web interface, you can also download Mattermost clients for Android, iOS, Windows PC, Mac OSX, and Linux.

Google Play App Store Windows PC Mac OSX Linux

Get Security Bulletins

Receive notifications of critical security updates. The sophistication of online attackers is perpetually increasing. If you are deploying Mattermost it is highly recommended you subscribe to the Mattermost Security Bulletin mailing list for updates on critical security releases.

Get Involved

Learn More

Get the Latest News

Any other questions, mail us at info@mattermost.com. Wed love to meet you!

Описание
No description provided
Readme 636 MiB
Languages
TypeScript 47%
Go 40.2%
JavaScript 8.6%
SCSS 2.8%
HTML 1.1%
Разное 0.2%