Home > Back-end >  WP Slow queries / Duplicated queries - images
WP Slow queries / Duplicated queries - images

Time:05-20

I have problems with slow and duplicated queries, I'll need assistance, I'm working on this for more than 10h .

Latest WP version - Latest Flatsome theme and just Query monitor and Woocommerce plugins installed.

The first slow query I wanna know more about is caller: update_metadata() - loading time 16sec



    UPDATE `wp_postmeta`
SET `meta_value` = 'a:5:{s:5:\"width\";i:550;s:6:\"height\";i:550;s:4:\"file\";s:55:\"dl/img/img_17758_af1c47d8fd932e4d88911acf423d03ca_1.jpg\";s:5:\"sizes\";a:1:{s:21:\"woocommerce_thumbnail\";a:4:{s:4:\"file\";s:56:\"img_17758_af1c47d8fd932e4d88911acf423d03ca_1-247x296.jpg\";s:5:\"width\";i:247;s:6:\"height\";i:296;s:9:\"mime-type\";s:10:\"image/jpeg\";}}s:10:\"image_meta\";a:12:{s:8:\"aperture\";s:1:\"0\";s:6:\"credit\";s:0:\"\";s:6:\"camera\";s:0:\"\";s:7:\"caption\";s:0:\"\";s:17:\"created_timestamp\";s:1:\"0\";s:9:\"copyright\";s:0:\"\";s:12:\"focal_length\";s:1:\"0\";s:3:\"iso\";s:1:\"0\";s:13:\"shutter_speed\";s:1:\"0\";s:5:\"title\";s:0:\"\";s:11:\"orientation\";s:1:\"0\";s:8:\"keywords\";a:0:{}}}'
WHERE `post_id` = 191595
AND `meta_key` = '_wp_attachment_metadata'



update_metadata()
wp-includes/meta.php:306
update_post_meta()
wp-includes/post.php:2537
wp_update_attachment_metadata()
wp-includes/post.php:6599
_wp_make_subsizes()
wp-admin/includes/image.php:452
wp_create_image_subsizes()
wp-admin/includes/image.php:368
wp_generate_attachment_metadata()
wp-admin/includes/image.php:486
WC_Regenerate_Images::resize_and_return_image()
wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:402
WC_Regenerate_Images::maybe_resize_image()
wp-content/plugins/woocommerce/includes/class-wc-regenerate-images.php:251
apply_filters('wp_get_attachment_image_src')
wp-includes/plugin.php:189
wp_get_attachment_image_src()
wp-includes/media.php:992
wp_get_attachment_image()
wp-includes/media.php:1029
flatsome_woocommerce_get_alt_product_thumbnail()
wp-content/themes/flatsome/inc/woocommerce/structure-wc-product-box.php:68
do_action('flatsome_woocommerce_shop_loop_images')
wp-includes/plugin.php:474
load_template('wp-content/themes/flatsome/woocommerce/content-product.php')
wp-includes/template.php:772
wc_get_template_part()
wp-content/plugins/woocommerce/includes/wc-core-functions.php:284
ux_products()
wp-content/themes/flatsome/inc/shortcodes/ux_products.php:263
do_shortcode_tag()
wp-includes/shortcodes.php:356
preg_replace_callback()
wp-includes/shortcodes.php:356
do_shortcode()
wp-includes/shortcodes.php:228
apply_filters('the_content')
wp-includes/plugin.php:189
the_content()
wp-includes/post-template.php:253

CREATE TABLE `wp_postmeta` (
  `meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
  `meta_key` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_value` longtext COLLATE utf8mb4_unicode_ci,
  PRIMARY KEY (`post_id`,`meta_id`),
  UNIQUE KEY `meta_id` (`meta_id`),
  KEY `post_id` (`post_id`,`meta_key`(32),`meta_value`(32),`meta_id`),
  KEY `meta_value` (`meta_value`(32),`meta_id`),
  KEY `meta_key` (`meta_key`)
) ENGINE=InnoDB AUTO_INCREMENT=2428790 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CodePudding user response:

Get rid of the (32) on meta_key -- it prevents use of the subsequent columns.

Install https://wordpress.org/plugins/index-wp-mysql-for-speed/

And/or see http://mysql.rjweb.org/doc.php/index_cookbook_mysql#speeding_up_wp_postmeta

  • Related