Midwest PHP 2018 Notes: Diving into MySQL 5.7 by Gabriela Ferra
Gabriela went over several of the new features in MySQL 5.7 and discussed the fact that 5.7 has a more strict set of settings to make sure you get the correct results.
Main Take Aways
- 5.7 has an inplace schema change option
- 5.7 has JSON support
- 5.7 has a
sys
schema that gives you information about slow queries and unused indexes
Things I’m Going to Do
Try upgrading all my application to 5.7. I tried one without adjusting the sql_mode and it cause a hugh failure rate on my integration tests.
My Raw Notes
- MySQL keeps getting more strict
- 5.7 appears to be overtaking 5.5
Online DDL changes
- Inplace or copy
- Inplace quicker
- use
ALGORITHM=INPLACE
- add index
- add virtual column
- varchar 1 to 255
- use
- Copy slower
- Droping column
- varchar 256+
JSON
- Can store JSON
- Use JSON_EXTRACT to get single field
- select JSON_EXTRACT(field, ‘$.nickname’) or select field->’$.nickname’
- will return quoted strings and null if value is missing
- select field-»’$.nickname’
- removes quotes from strings for easier reporting
- this method easier to read
$
refers to document itself
Generated Columns
- Virtual
- No disk space
- In-place change
- Value generated on demand and on every BEFORE trigger
- Stored
- Uses disk space
- Copy operation
- Updated on every INSERT and UPDATE
- Both
- Only know about their own table
- Must have a type
- Allows expressions
- operators (math)
- Built-in functions
- Literals
- Can be indexed
- Limitations
- Subquries not allowed
- Custom functions not supported
- Can’t rename the column
- Can’t use non-deterministric functions (IE now())*
note: When rows affected show up in alter table results it caused a rebuild*
Generated Columns and JSON indexing
- Can’t index json field directly
- Need to create generated column and then index that column*
sql_mode
- Determines how strict database is going to be
- In 5.7 MySQL when from 2 options to a bunch
- Don’t disable any fix your problems
sys
schema
- Don’t enable in production by default
- Used for critical analytical cases
- Allows you to create dashboards to show usage
- Show high cost SQL statements
- Top 5% of slow queries
- Show Unused index
- show full table scans
Other changes
- Passwords can have expiration dates
- Triggers now support more than one event per table
Scott Keck-Warren
Scott is the Director of Technology at WeCare Connect where he strives to provide solutions for his customers needs. He's the father of two and can be found most weekends working on projects around the house with his loving partner.
RSS
Top Posts
- Working With Soft Deletes in Laravel (By Example)
- Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
- Upgrading to Laravel 8.x
- Get The Count of the Number of Users in an AD Group
- Multiple Vagrant VMs in One Vagrantfile
- Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
- Changing the Directory Vagrant Stores the VMs In
- Accepting Android SDK Licenses From The OSX Command Line
- Fixing the 'Target class [config] does not exist' Error
- Using Rectangle to Manage MacOS Windows