-
Notifications
You must be signed in to change notification settings - Fork 19
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 indexes to database tables #41
Comments
Thank you for the suggestion @nekromoff. I love the idea of this and recognize it's need. That said, I'll admit I'm not overly familiar with how index work and how to best configure them. Would you be willing to commit a pull request with the required changes? Do you know of any good resources to help me better understand indexes, how to set them up, and how they operate? Thank you. |
Those times when I used to optimize MySQL performance are gone for me, but few basic rules:
Also: prepend any SELECT query with More on the topic: I have currently only tried to add these indexes for
|
BTW, yes, I can try to add indexes to the |
This is the primary select query that is used on all of the reports. Variables for the query get populated in the Reports class. Rather than try an muddle through the code, I'd suggest adding |
search_analytics seems like the only table worth indexing, but search_engine isn't used in reports, and is therefore not required. Since all of the queries use domain and a range of dates, I've changed the primary key to "domain, date, id" and converted the id index to unique. This way, that table is physically sorted by domain and date, ready for most queries. Sure enough, this index is used whenever the query and/or page match is set to "broad", and speed seems to be better than before, regardless of the query type. On 344MB of data, the index size is 60MB, which is roughly a 17% overhead. Adding indexes on domain, date and query or domain, date and page doesn't help, but when indexing on substrings, e.g. domain(50), date and query(255) OR page(255), they are used for the exact match queries, but not for broad matches. Therefore, the benefits are smaller. I've also converted the table to InnoDB storage, because I think it's faster and because it doesn't need to be maintained (analysed/repaired). Suggested SQL for this: CREATE TABLE `search_analytics` ( ALTER TABLE `search_analytics` ALTER TABLE `search_analytics` |
Specially important for handling large amounts of rows in
search_analytics
.Definitely index for
date
, maybe another combined fordate
,domain
andsearch_engine
for queries such as (inc/code/dataCapture.php
):etc.
The text was updated successfully, but these errors were encountered: