* 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>
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.
Try out Mattermost
- Join the Mattermost Contributor's server to join community discussions about contributions, development and more
- Join the Mattermost Demo server to try out Mattermost and explore sample use cases
Deploy on Heroku
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
- One-line Docker Preview
- Developer Machine Setup
- Production Install Guides using Linux Binary
- Production Docker Install
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.
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
- Contribute Code
- Find "Help Wanted" projects
- Join Developer Discussion on a Mattermost Server for contributors
- File Bugs
- Share Feature Ideas
- Get Troubleshooting Help
- Help translate Mattermost
Learn More
- API Options - webhooks, slash commands, drivers and web service
- See who's using Mattermost
- Browse over 700 Mattermost integrations
Get the Latest News
- Twitter - Follow Mattermost
- Blog - Get the latest updates from the Mattermost blog.
- Email - Subscribe to our newsletter (1 or 2 per month)
- Mattermost - Join the ~contributors channel on the Mattermost Community Server.
- IRC - Join the #matterbridge channel on Freenode (thanks to matterircd).
Any other questions, mail us at info@mattermost.com. We’d love to meet you!





