On Percona:
|
mysql> EXPLAIN SELECT wpsc_posts.* FROM wpsc_posts INNER JOIN wpsc_postmeta ON ( wpsc_posts.ID = wpsc_postmeta.post_id ) INNER JOIN wpsc_postmeta AS mt1 ON ( wpsc_posts.ID = mt1.post_id ) INNER JOIN wpsc_postmeta AS mt2 ON ( wpsc_posts.ID = mt2.post_id ) INNER JOIN wpsc_postmeta AS mt3 ON ( wpsc_posts.ID = mt3.post_id ) INNER JOIN wpsc_postmeta AS mt4 ON ( wpsc_posts.ID = mt4.post_id ) INNER JOIN wpsc_postmeta AS mt5 ON ( wpsc_posts.ID = mt5.post_id ) INNER JOIN wpsc_postmeta AS mt6 ON ( wpsc_posts.ID = mt6.post_id ) INNER JOIN wpsc_postmeta AS mt7 ON ( wpsc_posts.ID = mt7.post_id ) INNER JOIN wpsc_postmeta AS mt8 ON ( wpsc_posts.ID = mt8.post_id ) INNER JOIN wpsc_postmeta AS mt9 ON ( wpsc_posts.ID = mt9.post_id ) INNER JOIN wpsc_postmeta AS mt10 ON ( wpsc_posts.ID = mt10.post_id ) INNER JOIN wpsc_postmeta AS mt11 ON ( wpsc_posts.ID = mt11.post_id ) INNER JOIN wpsc_postmeta AS mt12 ON ( wpsc_posts.ID = mt12.post_id ) WHERE 1=1 AND ( ( wpsc_postmeta.meta_key = 'gender' AND wpsc_postmeta.meta_value = 'Female' ) AND ( mt1.meta_key = 'age' AND mt1.meta_value = '28-30' ) AND ( mt2.meta_key = 'actor_ethnicity' AND mt2.meta_value = 'Maltese' ) AND ( mt3.meta_key = 'complexion' AND mt3.meta_value = 'Fair Freckles' ) AND ( mt4.meta_key = 'natural_accent' AND mt4.meta_value = 'Maltese' ) AND ( mt5.meta_key = 'actor_height' AND mt5.meta_value = '66-70' ) AND ( mt6.meta_key = 'chest' AND mt6.meta_value = '813' ) AND ( mt7.meta_key = 'waist' AND mt7.meta_value = '6' ) AND ( mt8.meta_key = 'hip' AND mt8.meta_value = '191' ) AND ( mt9.meta_key = 'eye_colour' AND mt9.meta_value = 'Cyan' ) AND ( mt10.meta_key = 'hair_colour' AND mt10.meta_value = 'Pink' ) AND ( mt11.meta_key = 'male_clothing_size' AND mt11.meta_value = 'M' ) AND ( mt12.meta_key = 'female_clothing_size' AND mt12.meta_value = '88' ) ) AND wpsc_posts.post_type = 'actors' AND ((wpsc_posts.post_status = 'publish')) GROUP BY wpsc_posts.ID ORDER BY wpsc_posts.post_date DESC;
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-----------------------------------+------+----------+----------------------------------------------+
|
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-----------------------------------+------+----------+----------------------------------------------+
|
| 1 | SIMPLE | mt12 | NULL | ref | post_id,meta_key | meta_key | 767 | const | 16 | 10.00 | Using where; Using temporary; Using filesort |
|
| 1 | SIMPLE | wpsc_posts | NULL | eq_ref | PRIMARY,post_name,type_status_date,post_parent,post_author | PRIMARY | 8 | aditest_screk6qctors.mt12.post_id | 1 | 5.00 | Using where |
|
| 1 | SIMPLE | wpsc_postmeta | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt2 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt3 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt4 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt5 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt11 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt8 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt6 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt7 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt1 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt9 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
| 1 | SIMPLE | mt10 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctors.mt12.post_id | 7 | 0.69 | Using where |
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-----------------------------------+------+----------+----------------------------------------------+
|
14 rows in set, 1 warning (0.03 sec)
|
|
On MySQL 5.7.24:
|
mysql> EXPLAIN SELECT wpsc_posts.* FROM wpsc_posts INNER JOIN wpsc_postmeta ON ( wpsc_posts.ID = wpsc_postmeta.post_id ) INNER JOIN wpsc_postmeta AS mt1 ON ( wpsc_posts.ID = mt1.post_id ) INNER JOIN wpsc_postmeta AS mt2 ON ( wpsc_posts.ID = mt2.post_id ) INNER JOIN wpsc_postmeta AS mt3 ON ( wpsc_posts.ID = mt3.post_id ) INNER JOIN wpsc_postmeta AS mt4 ON ( wpsc_posts.ID = mt4.post_id ) INNER JOIN wpsc_postmeta AS mt5 ON ( wpsc_posts.ID = mt5.post_id ) INNER JOIN wpsc_postmeta AS mt6 ON ( wpsc_posts.ID = mt6.post_id ) INNER JOIN wpsc_postmeta AS mt7 ON ( wpsc_posts.ID = mt7.post_id ) INNER JOIN wpsc_postmeta AS mt8 ON ( wpsc_posts.ID = mt8.post_id ) INNER JOIN wpsc_postmeta AS mt9 ON ( wpsc_posts.ID = mt9.post_id ) INNER JOIN wpsc_postmeta AS mt10 ON ( wpsc_posts.ID = mt10.post_id ) INNER JOIN wpsc_postmeta AS mt11 ON ( wpsc_posts.ID = mt11.post_id ) INNER JOIN wpsc_postmeta AS mt12 ON ( wpsc_posts.ID = mt12.post_id ) WHERE 1=1 AND ( ( wpsc_postmeta.meta_key = 'gender' AND wpsc_postmeta.meta_value = 'Female' ) AND ( mt1.meta_key = 'age' AND mt1.meta_value = '28-30' ) AND ( mt2.meta_key = 'actor_ethnicity' AND mt2.meta_value = 'Maltese' ) AND ( mt3.meta_key = 'complexion' AND mt3.meta_value = 'Fair Freckles' ) AND ( mt4.meta_key = 'natural_accent' AND mt4.meta_value = 'Maltese' ) AND ( mt5.meta_key = 'actor_height' AND mt5.meta_value = '66-70' ) AND ( mt6.meta_key = 'chest' AND mt6.meta_value = '813' ) AND ( mt7.meta_key = 'waist' AND mt7.meta_value = '6' ) AND ( mt8.meta_key = 'hip' AND mt8.meta_value = '191' ) AND ( mt9.meta_key = 'eye_colour' AND mt9.meta_value = 'Cyan' ) AND ( mt10.meta_key = 'hair_colour' AND mt10.meta_value = 'Pink' ) AND ( mt11.meta_key = 'male_clothing_size' AND mt11.meta_value = 'M' ) AND ( mt12.meta_key = 'female_clothing_size' AND mt12.meta_value = '88' ) ) AND wpsc_posts.post_type = 'actors' AND ((wpsc_posts.post_status = 'publish')) GROUP BY wpsc_posts.ID ORDER BY wpsc_posts.post_date DESC;
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-------------------------------------+------+----------+----------------------------------------------+
|
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-------------------------------------+------+----------+----------------------------------------------+
|
| 1 | SIMPLE | mt12 | NULL | ref | post_id,meta_key | meta_key | 767 | const | 16 | 10.00 | Using where; Using temporary; Using filesort |
|
| 1 | SIMPLE | wpsc_posts | NULL | eq_ref | PRIMARY,post_name,type_status_date,post_parent,post_author | PRIMARY | 8 | aditest_screk6qctorsau.mt12.post_id | 1 | 5.00 | Using where |
|
| 1 | SIMPLE | wpsc_postmeta | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt2 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt3 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt4 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt5 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt11 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt8 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt6 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt7 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt1 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt9 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
| 1 | SIMPLE | mt10 | NULL | ref | post_id,meta_key | post_id | 8 | aditest_screk6qctorsau.mt12.post_id | 7 | 0.68 | Using where |
|
+----+-------------+---------------+------------+--------+------------------------------------------------------------+----------+---------+-------------------------------------+------+----------+----------------------------------------------+
|
14 rows in set, 1 warning (0.11 sec)
|
|
And some configurations:
|
1. One test MariaDB 10.1.37 server:
|
[mysqld]
|
datadir = /var/lib/mysql
|
log-error = /var/log/mysqld.log
|
socket = /var/lib/mysql/mysql.sock
|
symbolic-links = 0
|
user = mysql
|
query_cache_type=1
|
innodb_buffer_pool_size=512M
|
innodb_log_buffer_size=8M
|
innodb_buffer_pool_instances=1
|
query_cache_limit=4M
|
slow_query_log=1
|
query_cache_size=4M
|
skip_name_resolve=1
|
|
2. Another MariaDB , 10.1.36:
|
[mysqld]
|
skip-name-resolve=1
|
key_buffer_size = 128M
|
max_allowed_packet = 16M
|
table_cache = 500
|
sort_buffer_size = 8M
|
read_buffer_size = 4M
|
read_rnd_buffer_size = 4M
|
thread_cache_size = 8
|
query_cache_size = 24M
|
tmp_table_size = 2G
|
max_heap_table_size = 2G
|
innodb_buffer_pool_size=10G
|
innodb_buffer_pool_instances=10
|
innodb_log_buffer_size=32M
|
innodb_log_file_size=128M
|
log-warnings=2
|
max_connect_errors=1000
|
connect_timeout=600
|
net_read_timeout=600
|
max_connections = 101
|
max_user_connections=51
|
open-files-limit=8192
|
slow_query_log=on
|
tmpdir=/var/lib/mysql
|
|
3. Percona:
|
[mysqld]
|
server-id=1
|
datadir=/var/lib/mysql
|
socket=/var/lib/mysql/mysql.sock
|
log-error=/var/log/mysqld.log
|
pid-file=/var/run/mysqld/mysqld.pid
|
log-bin
|
max_binlog_files=20
|
symbolic-links=0
|
show_compatibility_56=1
|
skip_name_resolve=1
|
max_connections=101
|
wsrep_provider=/usr/lib64/galera3/libgalera_smm.so
|
wsrep_cluster_address=gcomm://192.168.1.181,192.168.1.182,192.168.1.183
|
binlog_format=ROW
|
default_storage_engine=InnoDB
|
wsrep_slave_threads= 8
|
innodb_autoinc_lock_mode=2
|
innodb_locks_unsafe_for_binlog=1
|
innodb_buffer_pool_instances=1
|
innodb_flush_log_at_trx_commit=0
|
wsrep_cluster_name=ddns-pxc-testcluster1
|
wsrep_node_name=ddns-pxc-testcluster1-node1
|
wsrep_sst_method=xtrabackup-v2
|
pxc_strict_mode=PERMISSIVE
|
log_timestamps=SYSTEM
|
enforce_storage_engine=InnoDB
|
query_cache_type=ON
|
query_cache_limit=16M
|
query_cache_size=16M
|
net_buffer_length=1000000
|
sort_buffer_size = 4M
|
read_buffer_size = 4M
|
max_allowed_packet = 16M
|
sql_mode=NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
|
|
4. On MySQL 5.7.24:
|
[mysqld]
|
skip_name_resolve = on
|
log_error=/var/log/mysqld.log
|
slow_query_log=1
|
slow_query_log_file=/var/log/mysqld.log
|
skip-log-bin
|
performance_schema = on
|
transaction-isolation = READ-COMMITTED
|
|
Any variables in particular you're interested in?
|