Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I found this query causing some load in the server, my hosting provdier asked me to look on it.

SELECT SQL_CALC_FOUND_ROWS  wp_posts 

I think this select no. rows found in wp_posts table.. but i tried to this query in separate page, it takes so long to complete the request.Can somebody help me to overcome from this issue?

Thanks!

share|improve this question
add comment

1 Answer 1

WordPress uses this feature of MySQL to get a total count of posts when you are only retrieving limited amount (100 posts total, but only 10 posts per page).

From quick look at source there is no_found_rows query argument that can disable it. That will wreck pagination and should only be used with specific queries that don't need counting (for example get_posts() uses it by default).

You probably need to look into performance of your database overall (if you are running something crazy large) or if there are issues with configuration (if you are running something small enough to not possibly cause issues with resources).

share|improve this answer
    
as you said, if it is used only for pagination means, can i query manually. something like "select count(*) from wp_posts"? doest it affects pagination and others contents? –  Sekar Jan 23 '12 at 12:34
    
@Sekar there is no guarantee that separate query would be any faster (it depends on database setup and I am not sure how would WP's database behave) and it sure would be huge pain to cleanly change from one to another. As per my answer I'd start looking into why it is slow instead of trying to get rid of it without insight into what is going on. –  Rarst Jan 23 '12 at 12:39
    
i'll try and let you know... thanks for efforts. –  Sekar Jan 23 '12 at 13:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.