Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABC-79: Optimize channel autocomplete query #8163

Merged
merged 2 commits into from
Jan 31, 2018

Conversation

ccbrown
Copy link
Contributor

@ccbrown ccbrown commented Jan 29, 2018

Summary

As discussed in this very long thread, this changes the autocomplete query to return an arbitrary subset of results rather than the first X in the complete, sorted result set.

The impact on some autocomplete searches on my local database with over ~400,000 in-team channels prefixed with "channel":

Search Term Before After
~ 7.65s 0.021s
~c 9.48s 2.83s
~ch 9.34s 1.89s
~cha 10.60s 1.48s
~t 7.68s 0.592s
~to 8.32s 0.027s
~tow 7.37s 0.023s

There are more things I could do to reduce those "~c..." cases down to a few milliseconds as well, but I'm suspecting that 400,000+ matching channels is not the norm, so it would probably be premature to put much effort into that.

Ticket Link

https://mattermost.atlassian.net/browse/ABC-79

I'm going to close this ticket with this PR as I think this resolves the biggest issues (The user performance isn't anywhere near as bad as the channel performance was.). We can create new issues as needed.

Checklist

N/A

@ccbrown ccbrown added 2: Dev Review Requires review by a developer 1: PM Review Requires review by a product manager labels Jan 29, 2018
@jasonblais
Copy link
Contributor

@ccbrown Are we going to apply the same to user autocomplete? (and perhaps emoji autocomplete)

@ccbrown
Copy link
Contributor Author

ccbrown commented Jan 29, 2018

@jasonblais I think we should, but I think we should make separate JIRA issues and PRs for them.

@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Jan 29, 2018
@jwilander
Copy link
Member

@jasonblais as is, this is going to change more than just the behaviour of the channel autocomplete but also anywhere we have channel search as well. The case I'm thinking of is in the 'More Channels' modal, it's going to be much faster but it's going to show arbitrary results like it will for the autocomplete. Is that OK?

Personally I think it makes more sense to have a dedicated autocomplete API endpoint for this fast query and the regular search endpoint is slower but more accurate. Or at least it should be a query parameter on the search endpoint

@jasonblais
Copy link
Contributor

@ccbrown Propose we only change the channel linking autocomplete. Other searches such as the "More Channels" dialog, results aren't expected to be arbitrary. Plus we might add paging to search results later, in which case we display more than just the first 100 results.

/cc @jwilander

Copy link
Contributor

@jasonblais jasonblais left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

Also, created a ticket for optimizing user autocomplete query. https://mattermost.atlassian.net/browse/ABC-201

ORDER BY DisplayName
LIMIT 100`
%v
LIMIT 50`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 50?

Copy link
Contributor Author

@ccbrown ccbrown Jan 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We mentioned reducing the number of results returned in our discussion, and there didn't seem to be any opposition to the idea. 50 is still twice as many results as slack (and 5x Discord).

@csduarte
Copy link
Contributor

Is it possible the new behavior is going to be hard on users? Is this something that could/should be feature flagged? @ccbrown

@ccbrown
Copy link
Contributor Author

ccbrown commented Jan 30, 2018

@jasonblais This review now changes no behavior, but adds an additional API endpoint for channel autocomplete. I'll put in the reviews for the 3 other repos that will need to be updated soon.

@csduarte I don't really think anyone will notice a difference in the results; only that they'll get autocomplete results potentially several hundred times faster.

@jasonblais jasonblais removed the Setup Old Test Server Triggers the creation of a test server label Jan 30, 2018
@mattermost mattermost deleted a comment from mattermod Jan 30, 2018
@mattermost mattermost deleted a comment from mattermod Jan 30, 2018
@mattermost mattermost deleted a comment from mattermod Jan 30, 2018
@jasonblais jasonblais added the Setup Old Test Server Triggers the creation of a test server label Jan 30, 2018
@jasonblais
Copy link
Contributor

@ccbrown

This review now changes no behavior, but adds an additional API endpoint for channel autocomplete

Do you mean "More Channels" search still shows X arbitrary results? Or only the channel autocomplete.

@ccbrown
Copy link
Contributor Author

ccbrown commented Jan 30, 2018

@jasonblais I mean absolutely no behavior is changing with this PR. Everything is exactly as it was before. The behavior will change once I get the other PRs in and have the client use the new endpoint that this adds.

@jasonblais
Copy link
Contributor

@ccbrown Mm, right. Got it. I'll test the client-side PR then.

@jasonblais jasonblais removed 1: PM Review Requires review by a product manager Setup Old Test Server Triggers the creation of a test server labels Jan 30, 2018
@jasonblais
Copy link
Contributor

@jwilander @grundleborg Ready for your reviews.

@jasonblais jasonblais added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a developer labels Jan 31, 2018
@jwilander jwilander merged commit e0ee73e into mattermost:master Jan 31, 2018
@amyblais amyblais added the Changelog/Done Required changelog entry has been written label Feb 1, 2018
@lindalumitchell lindalumitchell added the Tests/Not Needed New release tests not required label Feb 2, 2018
@amyblais amyblais added Docs/Needed Requires documentation Docs/Done Required documentation has been written and removed Docs/Needed Requires documentation Docs/Done Required documentation has been written labels Feb 2, 2018
@amyblais amyblais added Docs/Done Required documentation has been written and removed Docs/Needed Requires documentation labels Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request Changelog/Done Required changelog entry has been written Docs/Done Required documentation has been written Tests/Not Needed New release tests not required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants