Repository navigation
Database Optimizations - #3167
Conversation
- Add indexes to tables to improve query times. - Delete orphaned attribute values. - Resolve duplicate attribute values. - Deleted whitespace after migration which was causing Severity: Warning --> Cannot modify header information - headers already sent by
jekkos
left a comment
There was a problem hiding this comment.
Thanks I think we're good if we resolve the last comments in here.
- Removed unnecessary indices on deleted column where there would not be many rows. - Explicitly stated NULL in second parameter of WHERE to improve readability.
OK, then just the composite indices to figure out. I've pushed a commit that fixes the other issues. |
|
@jekkos I decided to just do the item model and here is what the better part of a day got me in terms of moving through each function that contained a select query and running MYSQL EXPLAIN against the query that gets generated (thanks for the tip on the $this->db->last_query() function). |
|
Also, if possible, since it takes so long to do, I'd like to limit this round of DB improvements to those affected by the Item and Attribute models. We can go back through and revamp the indexes on the other tables later if needed. I think an entire PR could be dedicated just to the Report model tables. |
- Removed unnecessary indices on deleted column where there would not be many rows. - Removed unnecessary parenthesis in Item Model. - Added Composite indices based on MySQL EXPLAIN results.
|
@jekkos, @opensourcepos/org I removed the deleted indexes on a few of the tables and added a few composite indices (see below) based on the results of the explain. Can we move on this yet? |
|
@objecttothis thanks for the good work here, I didn't have too much time to look in to it yet thoroughly,
The items / inventory table is enough for now. I think that is typically the table that has most of the data. Also running a report is not something that is used that often, it can be done afterwards as it might be acceptable to be a little bit slower. |
|
Were you able to verify that the queries use the composite index ? I think it would already be a great improvement if an index is able to accelerate the commonly used Item->search() query. |
I'll confirm that they are using the indexes. |
|
Ok I have merged this change already. Minor nitpick maybe try to refer to an issue number in your commit message next time, it makes the git changelog better as you can find more info about a changeset under the github issue tracker. |


This is the first of four PRs that I will break out of the big import_update branch, so that it's easier to test and merge. Those having issues with large product stocks should see immediate improvement in transactions.