0

For a few months now, i'm facing a lot of difficulties with one of my websites being too slow and i'm guessing the reason behind this could be the number of queries.

At the moment these are the number of queries on my website: Homepage = 423 queries in 6.098 seconds Single = 354 queries in 1.593 seconds Category = 286 queries in 1.314 seconds

For the most part of the website, i'm pulling posts/articles from different categories by using WP_Query.

This is the code i use, and i do use it a lot. Sometimes 4-5 times on a single page:

$count = 0;
$args = array(
    'posts_per_page'=>5,
    'orderby'=>'date',
    'cat'=>'9',
    'order'=>'desc',
    /* 'post__not_in'=>get_option("sticky_posts") */
);

$custom_query = new WP_Query($args);
while($custom_query->have_posts()) : $custom_query->the_post();

Do you think the slow speed of my website is caused by the number of queries? If so, is there an alternative way for pulling posts/articles without so many queries?

Thanks for your time

UPDATE I've disabled all plugins / deleted all queries in frontpage, but still the memory usage is high. 71.61mb and 332queries. There is one query which seems to be the root of the problem but i don't know where it comes from:

SELECT wp_posts.*
FROM wp_posts
WHERE 1=1
AND wp_posts.ID IN     (264,402,437,438,538,682,664,640,935,978,1132,1128,1015,1136,1130,1580,1602,1641,1655,1657,1669,1709,1707,1716,1723,1722,1768,1778,1789,1797,1807,1806,1802,1825,1824,1868,1877,1983,1940,2033,2078,2073,2063,2067,2083,2101,2109,2111,2089,2154,2118,2114,2175,2164,2211,2230,2195,2232,2245,2242,2273,2254,2302,2306,2341,2364,2379,2361,2390,2421,2441,2456,2416,2465,2460,2482,2501,2503,2528,2534,2564,2586,2617,2649,2647,2654,2665,2683,2685,2688,2717,2742,2747,2758,2755,2787,2795,2808,2814,2818,2819,2826,2778,2847,2837,2869,2879,2897,2899,2891,2947,2957,2946,2968,3004,3010,3016,3028,2985,3002,3061,3060,3078,3067,3053,3092,3131,3151,3178,3168,3227,3247,3255,3262,3265,3273,3278,3365,3308,3375,3383,3409,3404,3420,3412,3416,3467,3482,3543,3535,3560,3563,3387,3596,3603,3605,3621,3620,3650,3640,3662,3668,3676,3699,3709,3712,3729,3727,3763,3799,3789,3839,3830,3819,3860,3881,3904,3888,3920,3919,3935,3962,3974,3977,3993,3997,4010,4025,4024,4035,4040,4039,4061,4063,4057,4086,4124,4137,4139,4146,4153,4157,4167,4170,4171,4186,4191,4192,4258,4358,4362,4379,4388,4404,4416,4429,4466,4480,4487,4505,4510,4516,4535,4551,4553,4556,4565,4595,4600,4696,4703,4714,4728,4756,4770,4785,4775,4809,4783,4807,4823,4835,4876,4914,4931,4934,4943,4955,4977,5003,5051,5082,5160,5168,5178,5181,5186,5193,5205,5195,5194,5236,5244,5255,5344,5477,5493,5495,5514,5520,5530,5534,5565,5581,5585,5576,5611,5620,5622,5633,5648,5649,5653,5685,5697,5706,5712,5716,5729,5746,5749,5815,5836,5873,4978,5927,5955,5957,5994,6007,6011,6018,6026,6036,6042,6050,6076,6015,6088,6111,6139,6142,6157,6169,6173,6181,6183,6189,6192,6211,6215,6228,6237,6250,6271,6286,6291,6295,6298,6301,6304,6324,6327,6325,6336,6366,6406,6446,6460,6468,6476,6478,6480,6514,6518,6534,6539,6551,6582,6584,6586,6588,6633,6635,6644,6676,6697,6701,6703,6705,6729,6731,6733,6735,6746,6749,6755,6799,6807,6812,6816,6864,6869,6873,6881,6883,6891,6897,6915,6921,6923,6987,6993,6995,7001,7003,7005,7023,7036,7053,7055,7059,7088,7156,7162,7185,7191,7193,7195,7201,7203,7213,7227,7239,7265,7297,7299,7304,7337,7349,7373,7380,7381,7383,7421,7442,7458,7466,7495,7509,7515,7524,7552,7572,7599,7615,7623,7627,7640,7673,7693,7711,7724,7736,7742,7756,7766,7785,7787,7789,7798,7808,7849,7877,7894,7899,7900,7907,7772,7920,7933,7958,7970,8011,8031,8066,8135,8141,8168,8173,8198,8187,8211,8224,8191,8291,8298,8300,8303,8308,8310,8314,8345,8371,8404,8434,8443,8465,8504,8530,8534,8536,8540,8548,8558,8568,8604,8614,8618,8625,8622,8635,8643,8677,8681,8691,8702,8737,8743,8745,8747,8753,8761,8880,8882,8896,8902,8917,8932,8934,8936,8945,8948,8915,8961,8970,8987,8996,526,9025,9033,9040,9043,9049,9067,9071,9077,9099,9095,9145,9147,9037,9154,9166,9168,9197,9216,9267,9275,9281,9285,9308,9310,9313,9325,9333,9341,9348,9353,9359,9386,9409,9437,9462,9485,9495,9502,9552,9535,9562,9603,9623,9684,9687,9691,9694,9698,9794,9798,9803,9900,9979,9982,9984,10007,10009,10015,10022,10050,10068,10070,10071,10077,10097,10096,10216,10218,10220,10222,10230,10233,10235,10242,10249,10261,10279,10300,2620,10315,10319,10339,10343,10353,10365,10371,10372,10395,10397,10411,10425,10460,10463,10465,10467,10478,10526,10539,10543,10549,10557,10564,10566,10575,10595,10597,10591,10660,10674,10702,10704,10708,10715,10719,10727,10739,10761,10773,10812,10827,10913,10953,10933,10973,10982,10984,10999,11001,11092,11101,11105,11111,11153,11171,11173,11180,11190,11211,11214,11218,11220,11223,11225,11233,11239,11255,11276,11275,11339,11344,11382,11387,11413,11417,11426,11438,11453,11391,11396,11520,11597,11621,11633,11636,11657,11666,11668,11677,11703,11705,11707,11709,11724,11730,11734,11736,11793,11797,11801,11809,11845,11853,11870,11882,11938,11940,11950,11955,11956,11960,11997,11999,12003,12013,12019,12024,12033,12035,12041,12058,12080,12082,12098,12100,12102,12104,12107,12109,12146,12151,12184,12190,12188,12204,12208,12210,12223,12246,12265,12267,12282,12284,12293,12307,12318,12323,12328,12345,12365,12369,12378,12390,12398,12404,12406,12415,12431,12433,12435,12467,12517,12542,12546,12575,12583,12637,12645,12650,12653,12664,12606,12668,12672,12685,12694,12699,12760,12772,12841,12849,12855,12857,12863,12865,12868,12875,12898,12918,12935,12992,12958,13002,12998,13008,13001,13019,13029,13051,13061,13063,13065,13067,13073,13075,13077,13101,13114,13116,13131,13135,13137,13143,13153,13196,13197,13199,13212,13216,13223,13234,13242,13246,13252,13258,13270,13279,13304,13339,13341,13345,13367,13373,13379,13416,13419,13421,13440,13484,13494,13500,13514,13529,13359,13555,13599,13627,13641,13669,13671,13673,13697,13713,13829,13844,13851,13861,13869,13885,13902,13912,13919,13817,13930,13935,13939,13954,13965,13970,14059,14058,14067,14071,14081,14128,14149,14151,14153,14164,14181,14185,14209,14215,14219,14232,14236,14238,14240,14250,14254,14259,14262,14283,14296,14299,14304,14303,14309,14311,14326,14331,14339,14368,14376,14380,14390,14394,14400,14405,14419,13503,14427,14434,14438,14440,14443,14448,14450,14459,14462,14472,14479,14494,14509,14512,14524,14526,14539,14563,14610,14615,14617,14629,14637,14654,14656,14660,14671,14285,14760,14756,14782,14784,14806,14816,14869,14882,14899,14923,14868,14931,14957,14962,14964,14968,14966,14970,14976,14978,14980,14990,14998,15009,15011,15013,15015,15025,15044,15001,14994,15061,15126,15134,15136,15150,15178,15180,15182,15186,15188,15203,15226,15233,15235,15245,15257,15259,15413,15419,15425,15433,15448,15450,15452,15460,15474,15483,15485,15489,15507,15521,15527,15529,15532,15539,15545,15563,15573,15582,15583,15585,15595,15611,15613,15631,15633,15642,15660,15667,15677,15681,15683,15696,15704,15706,15725,15729,15751,15777,15781,15787,15807,15847,15856,15889,15897,15905,15908,15914,15925,15933,15940,15946,15951,15973,15974,15977,15988,15992,15994,16005,16027,16029,16031,16039,16047,16049,16051,16053,16057,16058,16063,16070,16074,16098,16119,16159,16188,16195,16224,16236,16242,16244,16247,16253,16263,16270,16273,16272,16284,16298,16350,16379,16389,16435,16437,16439,16444,16448,16454,16463,16465,16498,16504,16508,16524,16526,16536,16542,16553,16559,16771,16792,16796,16806,16826,16843,16862,16866,16875,16929,16931,16935,17094,17100,17104,17180,17182,17195,17198,17211,17223,17227,17233,17237,17257,17275,17282,17290,17292,17320,17322,17326,17334,17336,17339,17333,17346,17365,17391,17419,17501,17505,17459,17527,17535,17543,17548,17554,17559,17572,17592,17598,17604,17610,17616,17624,17628,17630,17637,17677,17679,17681,17683,17693,17701,17703,17784,17866,17917,17927,17931,17948,17945,17978,18002,18010,18012,18028,18095,18073,18103,18115,18124,18126,18132,18150,18152,18158,18170,18182,18204,18220,18218,18225,18238,18240,18280,18295,18303,18305,18311,18325,18349,18375,18377,18480,18482,18484,18486,18488,18501,18503,18621,18781,18783,18802,18804,18819,18821,18845,18873,19007,19014,19021,19109,19113,19120,19131,19140,19146,19156,19163,19175,19180,19184,19194,19208,19244,19254,19243,19264,19267,19356,19363,19377,19453,19460,19475,19479,19483,19487,19504,19530,19747,19754,19758,19770,19780,19796,19800,19809,19833,19849,19873,19902,19904,19913,19925,19934,19941,19945,19967,19984,19988,20049,20051,20053,20061,20075,20084,20092,20103,20131,20129,20151,20138,20183,20191,20193,20218,20225,20227,20249,20258,20270,20276,20280,20332,19500,20338,20343,20354,20356,20366,20422,20425,20434,20438,20450,20466,20471,20502,20508,20543,20552,20554,20562,20568,20571,20580,20582,20584,20602,20620,20622,20650,20677,20703,20705,20709,20715,20723,20725,20742,20748,20774,20785,20787,20793,20795,20797,20820,20832,20838,20851,20864,20860,20872,20871,20892,20901,20912,20914,20916,20926,20936,20942,20948,20956,20960,20964,20972,20983,21007,21015,21017,21028,21032,21034,21036,21052,21096,21102,21165,21183,21213,21222,21236,21258,21262,21271,21285,21326,21328,21365,21373,21322,21458,21460,21487,21546,21550,21562,21568,21573,21579,21630,21632,21636,21638,21741,21748,21750,21873,21879,21881,21887,21891,21911,21922,21978,21976,21984,22105,22111,22115,22203,22215,22217,22213,22229,22253,22257,22263,22267,22274,22337,22349,22359,22371,22382,22384,22480,22518,22531,22537,22550,22571,22577,22579,22594,22598,22616,22628,22656,22666,22676,22680,22724,22738,22755,22751,22767,22778,22820,22823,22825,22899,22900,22915,22939,22964,22970,22972,22991,23021,23039,23046,23055,23065,23084,23091,23138,23140,23142,23172,23213,23227,23256,23280,23284,23305,23309,23311,23330,23359,23387,23398,23405,23411,23415,23491,23493,23576,23578,23581,23583,23592,23607,23623,23627,23647,23726,23728,23730,23743,23752,23883,23897,23909,23923,23925,23927,23930,23936,23940,23965,23981,23986,23992,24002,24059,24066,24068,24073,24071,24091,24109,24125,24134,24144,24146,24155,24183,24189,24191,24200,24215,24219,24223,24227,24239,24243,24251,24282,24307,24292,24321,24323,24325,24478,24481,24489,24491,24520,24524,24528,24536,24540,24551,24553,24585,24630,24637,24643,24654,24664,24666,24672,24680,24692,24737,24748,24750,24766,24788,24786,24800,24806,24814,24820,24839,24844,24855,24863,24860,24866,24914,25014,25028,25030,25032,25038,25056,25062,25113,25117,25120,25122,25125,25169,25180,25184,25256,25267,25274,25278,25300,25310,25332,25334,25349,25352,25384,25386,25389,25399,25403,25455,25461,25463,25472,25480,25484,25496,25506,25512,25528,25530,25534,25536,25563,25572,25581,25595,25688,25751,25763,25777,25784,26165,26173,26183,26185,26195,26205,26207,26213,26215,26219,26223,26229,26232,26234,26236,26238,26244,26251,26253,26263,26272,26278,26315,26325,26327,26392,26407,26414,26416,26419,26429,26431,26433,26439,26444,26456,26458,26460,26464,26472,26503,26509,26511,26515,26517,26519,26522,26528,26530,26537,26540,26542,26545,26551,26563,26565,26568,26578,26580,26586,26588,26591,26594,26600,26613,26620,26622,26624,26627,26629,26631,26633,26637,26650,26669,26675,26684,26695,26697,26716,26718,26722,26732,26745,26749,26752,26750,26754,26762,26764,26771,26776,26796,26828,26834,26846,26854,26856,26863,26867,26870,26875,26896,26898,26900,26791)
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.post_date DESC
  • Good crap, the numbers is totally insane. Normally you have round about 30 queries per page load. Your lowest, 286 queries is already totally insane. No wonder your page loads is so slow. Download and install Query Monitor and check where this is coming from. Take your site offline before doing this, as the plugin prints everything to screen. This will look really strange to people visiting your site – Pieter Goosen Jun 18 '15 at 14:53
  • It seems like the issue isn't any one thing. That query is pretty terrible, but that is only one of ~300. I don't think anyone can provide a specific answer to this question. Also, in case anyone was wondering, there are 1745 IDs in that query. – Mathew Tinsley Jun 19 '15 at 3:33
  • The weird thing is that i've removed all queries but still... there are queries according to the plugin "Query Monitor" :/ – user2093301 Jun 19 '15 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.