In the last few months we've migrated a few tables from MYiSAM to InnoDB. We did this, in theory, for the row locking advantage, since we are updating individual rows, through multiple web-scraping instances. I now have tens of thousands of slow_queries building up in my slow_query_log (10s). and a lot of full table scans. I am having event very simple updates to one row (updating 4 or 5 columns) take 28 seconds. (our i/o and efficiencies are very good, and failed/aborted attempts are very low < 0.5%)
The two tables we update the most have ID (int 11) as the primary key. In InnoDB the primary key is a clustered key, so are written to disk indexed in the order of ID. BUT our two most important record identifying columns are BillsofLading
and Container
(both varchar22). Most of our DML queries look up records based on these two columns. We also have indexes on BillsofLading
and container.
The way I understand it, InnoDB also uses the primary key when creating these two secondary indexes.
So, I could have a record with ID
=1, and BillsofLading
='z', and another record ID
=9 and BillsofLading
='a'. With InnoDB indexes, when updating record based on a SELECT where BillsofLading
='a', would I not still have to do a full scan to find 'a' since the index is based on the ID
?
Thanks in advance for helping with the logic here!