Thanks for the reply.
The bottleneck appears to be when “ORDER BY meta_id ASC;” is in the query with the high performance keys which results in a high creating sort time.
Here is a profile of the query with high performance indexes on the postmeta table taking .13s:
Duration: 0.13756471s
Starting: 0.000143s
checking permissions: 0.000006s
Opening tables: 0.000009s
After opening tables: 0.000007s
System lock: 0.000004s
table lock: 0.000005s
init: 0.000080s
Optimizing: 0.000033s
Statistics: 0.000248s
Preparing: 0.000017s
Sorting result: 0.000006s
Executing: 0.000004s
Sending data: 0.000006s
Creating sort index: 0.136885s
End of update loop: 0.000020s
Query end: 0.000004s
Commit: 0.000004s
Query end: 0.000004s
closing tables: 0.000004s
Unlocking tables: 0.000004s
closing tables: 0.000005s
Query end: 0.000005s
Starting cleanup: 0.000004s
Freeing items: 0.000016s
Updating status: 0.000013s
Logging slow query: 0.000024s
Reset for next command: 0.000006s
ALTER TABLE
wp_postmeta
ADD PRIMARY KEY (post_id
,meta_key
,meta_id
),
ADD UNIQUE KEY meta_id
(meta_id
),
ADD KEY meta_key
(meta_key
,meta_value
(32),post_id
,meta_id
),
ADD KEY meta_value
(meta_value
(32),meta_id
);
Postmeta rows: 2,019,801 461.4 MiB
And a profile with the standard indexes taking .05s
Query ID: 1 Duration: 0.05160964s
Starting: 0.000139s
checking permissions: 0.000006s
Opening tables: 0.000009s
After opening tables: 0.000006s
System lock: 0.000005s
table lock: 0.000005s
init: 0.000084s
Optimizing: 0.000035s
Statistics: 0.000251s
Preparing: 0.000027s
Sorting result: 0.000006s
Executing: 0.000004s
Sending data: 0.000006s
Creating sort index: 0.050946s
End of update loop: 0.000019s
Query end: 0.000005s
Commit: 0.000004s
Query end: 0.000004s
closing tables: 0.000004s
Unlocking tables: 0.000004s
closing tables: 0.000004s
Query end: 0.000005s
Starting cleanup: 0.000004s
Freeing items: 0.000015s
Updating status: 0.000009s
Reset for next command: 0.000006s
ALTER TABLE
wp_postmeta
ADD PRIMARY KEY (meta_id
),
ADD KEY post_id
(post_id
),
ADD KEY meta_key
(meta_key
(191));
Postmeta rows: 1,759,255 294.0 MiB
Could the longer times simply be from the larger database size with the extra indexes?