Title: Problems with SQL Queries
Last modified: August 18, 2016

---

# Problems with SQL Queries

 *  [borbs](https://wordpress.org/support/users/borbs/)
 * (@borbs)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/)
 * Hello! Since I updated the WordPress, I started to have some “high load” problems
   in my database. My server (mosso) said that this are the problematic queries:
 *     ```
       SELECT wp_posts.*, MAX(comment_date) AS max_comment_date FROM wp_comments, wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE wp_posts.post_date <= '2007-08-06 11:02:35' AND ( wp_posts.post_status = 'publish' OR wp_posts.post_status = 'sticky' ) AND wp_posts.post_password = '' AND wp_posts.ID = wp_comments.comment_post_ID AND wp_comments.comment_approved = '1' AND ( wp_post2cat.category_id = '20' OR wp_post2cat.category_id = '21' OR wp_post2cat.category_id = '22' OR wp_post2cat.category_id = '23' OR wp_post2cat.category_id = '24' OR wp_post2cat.category_id = '201' OR wp_post2cat.category_id = '202' OR wp_post2cat.category_id = '203' OR wp_post2cat.category_id = '25' OR wp_post2cat.category_id = '26' OR wp_post2cat.category_id = '27' OR wp_post2cat.category_id = '28' OR wp_post2cat.category_id = '29' OR wp_post2cat.category_id = '251' OR wp_post2cat.category_id = '30' OR wp_post2cat.category_id = '31' OR wp_post2cat.category_id = '32' OR wp_post2cat.category_id = '33' OR wp_post2cat.category_id = '34' OR wp_post2cat.category_id = '35' OR wp_post2cat.category_id = '301' OR wp_post2cat.category_id = '37' OR wp_post2cat.category_id = '38' OR wp_post2cat.category_id = '39' OR wp_post2cat.category_id = '40' OR wp_post2cat.category_id = '401' OR wp_post2cat.category_id = '402' OR wp_post2cat.category_id = '43' OR wp_post2cat.category_id = '44' OR wp_post2cat.category_id = '45' OR wp_post2cat.category_id = '46' OR wp_post2cat.category_id = '431' OR wp_post2cat.category_id = '432' OR wp_post2cat.category_id = '433' ) GROUP BY wp_posts.ID ORDER BY max_comment_date DESC LIMIT 0, 4 |
   
       | 904 | 331538_v6_main | 172.16.12.206:41472                    | 331538_v6_main | Query       |    0 | Copying to tmp table                                           | SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE wp_posts.post_date <= '2007-08-06 11:02:36' AND ( wp_posts.post_status = 'publish' OR wp_posts.post_status = 'sticky' ) AND wp_posts.post_password = '' AND ( wp_post2cat.category_id = '21' OR wp_post2cat.category_id = '26' OR wp_post2cat.category_id = '31' OR wp_post2cat.category_id = '37' OR wp_post2cat.category_id = '44' OR wp_post2cat.category_id = '8' OR wp_post2cat.category_id = '52' OR wp_post2cat.category_id = '53' OR wp_post2cat.category_id = '54' OR wp_post2cat.category_id = '55' OR wp_post2cat.category_id = '56' ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 14
       ```
   
 * What does it mean? How can I solve this problem? Please, help me! =]

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [mrmist](https://wordpress.org/support/users/mrmist/)
 * (@mrmist)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/#post-607575)
 * I’m not suprised. That’s not a nice query at all. On some RDBMs it wouldn’t even
   work at all because the components of the SELECT list are not either covered 
   by the group by or involved in aggregates.
 * As for what you can do about it, I’m not sure. The query can probably be optimised,
   but it depends how it’s generated from where to do what?
 *  Thread Starter [borbs](https://wordpress.org/support/users/borbs/)
 * (@borbs)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/#post-607580)
 * I don’t know where is this from. I’ll try to look in all my plugins and see if
   it works… But, if somebody knows anything, please, let me know. 🙂
 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/#post-607583)
 * It doesn’t seem to be a WP query. Most likely it is a plugin.
 *  Thread Starter [borbs](https://wordpress.org/support/users/borbs/)
 * (@borbs)
 * [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/#post-607589)
 * The problem is the Customizable Post Listings plugin.
    I disabled part of it,
   but I really need this plugin… Does anybody know some other that works like this?

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Problems with SQL Queries’ is closed to new replies.

## Tags

 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [query](https://wordpress.org/support/topic-tag/query/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [borbs](https://wordpress.org/support/users/borbs/)
 * Last activity: [18 years, 10 months ago](https://wordpress.org/support/topic/problems-with-sql-queries/#post-607589)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
