Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#41223 closed defect (bug) (duplicate)

wp_posts are very slow on larger sites

Reported by: lubimow's profile lubimow Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Database Keywords:
Focuses: Cc:

Description

I have Wordpress version 4.8 installed. But in a log of slow queries, I constantly have similar messages.

# Time: 2017-07-02T10:04:13.180832Z
# User@Host: site_234[site_234] @ localhost []  Id: 1226011
# Query_time: 2.109665  Lock_time: 0.000051 Rows_sent: 3  Rows_examined: 183299
SET timestamp=1498989853;
SELECT ID FROM wp_posts where guid = 'https://example.org/uploads/500.jpg' AND post_type = 'attachment';

When I search for a photo by title in the media library, each found photo is displayed here with this code in the slow query log

Change History (6)

#1 @windyjonas
8 years ago

Possible duplicate: #7633

#2 follow-up: @jrchamp
8 years ago

Hi @lubimow! The slow query you mentioned does not appear to be coming from WordPress core (the lowercase 'where' is very suspicious). It is likely coming from a plugin or your theme. For your site, you may want to consider adding an index to the guid column in the wp_posts table if the plugin/theme author is unable to provide fix.

#3 in reply to: ↑ 2 @lubimow
8 years ago

Replying to jrchamp:

Hi @lubimow! The slow query you mentioned does not appear to be coming from WordPress core (the lowercase 'where' is very suspicious). It is likely coming from a plugin or your theme. For your site, you may want to consider adding an index to the guid column in the wp_posts table if the plugin/theme author is unable to provide fix.

Thanks for the advice, and what should I do if I use innodb
I was told that your advice would not work on innodb

#4 @SergeyBiryukov
8 years ago

  • Component changed from General to Database

#5 follow-up: @pento
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.8 deleted

Thanks for the ticket, @lubimow!

This still has the same answer as #7633 - we don't select by the guid field in Core, so won't be adding an index to fix this.

As @jrchamp suggested, a custom index would help - perhaps on (guid, post_type), going by the query to posted. This will help if you're using MyISAM, InnoDB, or just about any other database engine.

That said, I would strongly recommend contacting the plugin author directly, they're welcome to add an index that helps their queries, though it's generally better to rewrite the query to use already indexed columns.

#6 in reply to: ↑ 5 @lubimow
8 years ago

Replying to @pento :

This is not a plug-in, it's search by media gallery and search when adding links in wordpress

Note: See TracTickets for help on using tickets.