When INSERTING does the order of columns in the SQL statement make any difference? Particularly with regard to BLOB types?
I'm assuming the answer is NO but the answers I've found so far are focused on SELECTS query performance. Example 1, Example 2
DETAILS:
There has been a refactor of an application using this DB and I'm seeing insert performance degrade as the table grows in rows. I did not see any degradation in insert performance previously.
- The MySQL db is literally the same between the old app and the new app: same config settings, same table structure. Therefore while DB config optimizations may be applicable here, at the moment I'm trying to understand why there is a difference in INSERT query performance.
- On the app side it's the same db driver between old and new app
- There is a difference in the persistence code (JDBC Template vs Hibernate) and one difference I see is the SQL INSERT statements were previously generated with the BLOB column (longblob) as the last column and now the SQL INSERT is generated with BLOB as one of the columns in the middle of the statement.
- The data being inserted is for the most part the same between the old and new app.
- Commits are being issued in the same manner and frequency.
Yes, I understand there are other factors at play in this scenario but I figured I'd just confirm INSERT column ordering does not matter when inserting BLOB types.
EDIT 1: By performance degradation I mean the following:
- The time it takes to insert 100k rows (in 1k per commit) increases from about 25 seconds per 100k to 27, 30, 35 seconds for each new 100k batch. Since this is a test db I am able to clear the data as needed.
- I did not see this behavior before and still do not see it on HSQL.
- I'm measuring time to insert 100k on the app side.
Edit 2: I'm using version 5.6.20 so Explain is not available on INSERT. However, I did use show profile as described here. Oddly MySQL reports the duration of the new query as much faster than the old query (which I am struggling to understand)
New query duration: 0.006389
Old query duration: 0.028531