-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Add index on Channel::hostname to prevent table scan on each request #9081
Conversation
Thanks Stefan! 🥇 |
@@ -0,0 +1,28 @@ | |||
<?php declare(strict_types = 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something went wrong here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it go away? Not sure it makes a lot of difference on a migration though, but it's good to be strict on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just prefer to be coherent here. If you have a free moment I would love to merge a PR :)
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20180102140039 extends AbstractMigration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing final?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other migrations I checked also didn't have final. Should I add it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion :) I believe, that migration shouldn't be extended at all, but not sure about BC here ;)
The first query occuring on each request in my app does a call to the
ChannelRepository::findOneByHostname
method from theHostnameBasedRequestResolver::findChannel
method, resulting in a query looking like this:It takes 17ms in my local development box, and the
EXPLAIN
looks like:Basically it is doing a table scan (even though small, probably nobody has that much queries).
Adding an index on the
hostname
column (maybe we should even make it unique, but that's another discussion and harder to upgrade) brings the query time back to 2ms for me and results in the followingEXPLAIN
: