Search
Other Articles Field questions
Forum

Reduce queries for high DB queries with ArticleFields

Hitsch's Avatar Hitsch
Our DB server suffers from high DB queries. Primarily responsible are queries that contain article fields. What can we do to optimise them? In which direction should we search?
Ex. 1
SELECT `article`.`id` AS `article.id`
FROM `jsmwh_content` AS `article`
LEFT JOIN `jsmwh_fields` AS `field-sendedatum` ON `field-sendedatum`.`name` = 'sendedatum' AND `field-sendedatum`.`state` = 1 AND `field-sendedatum`.`context` = 'com_content.article'
LEFT JOIN `jsmwh_fields_values` AS `field_value-sendedatum` ON `field_value-sendedatum`.`field_id` = `field-sendedatum`.`id` AND `field_value-sendedatum`.`item_id` = article.id
WHERE `article`.`id` IN (5,7,9,10,11,19,21,22,23,24,25,27,28,29,30,31,32,34,36,42,43,76,84,85,87,88,98,100,102,104,105,106,107,108,110,111,112,113,114,116,117,119,120,121,122,126,127,128,129,130,131,133,134,135,136,138,139,140,141,143,144,145,146,147,148,149,150,192,193,194,195,196,197,198,200,201,203,204,205,206,207,208,209,213,214,215,216,222,224,225,227,228,235,236,255,257,258,298,300,306,307,310,311,312,313,315,316,317,318,319,320,326,327,361,362,371,374,375,378,383,385,386,391,401,403,404,408,413,414,415,416,417,420,421,425,428,437,448,451,457,462,469,470,471,472,475,476,477,478,479,480,481,483,485,486,487,491,493,509,510,516,518,523,524,527,530,549,550,551,553,554,555,556,557,558,559,560,561,562,563,564,565,566,567,568,569,570,571,573,574,575,579,580,581,583,584,585,586,587,588,590,592,597,604,605,607,614,620,621,625,627,628,629,630,631,632,634,638,645,651,656,662,665,670,672,675,676,677,678,680,687,693,699,700,701,704,705,706,707,720,724,727,728,729,730,731,734,735,736,737,738,741,742,743,744,745,746,747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,770,772,774,776,784,786,794,829,832,834,835,837,841,845,846,848,854,855,858,859,864,867,871,876,880,882,883,886,887,890,891,892,899,905,909,911,913,914,915,917,918,920,921,922,923,924,925,927,928,929,930,931,934,935,936,937,938,941,943,944,946,947,948,949,950,952,953,954,955,956,957,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,976,984,992,997,999,1007,1013,1016,1017,1019,1021,1022,1024,1026,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1042,1049,1051,1052,1053,1054,1055,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1080,1089,1092,1094,1095,1096,1105,1107,1118,1121,1122,1126,1127,1128,1131,1132,1133,1134,1135,1136,1137,1138,1139,1142,1146,1152,1153,1155,1156,1157,1158,1159,1160,1162,1164,1165,1168,1169,1170,1172,1173,1174,1175,1176,1186,1191,1194,1195,1196,1197,1200,1201,1202,1203,1204,1208,1209,1210,1211,1214,1215,1216,1217,1218,1221,1222,1223,1224,1225,1226,1227,1228,1229,1231,1232,1233,1235,1237,1238,1239,1240,1308,1311,1315,1320,1321,1322,1324,1326,1328,1331,1337,1342,1345,1348,1349,1354,1355,1356,1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1367,1368,1370,1379,1382,1383,1385,1386,1387,1388,1389,1390,1391,1393,1395,1396,1397,1398,1399,1400,1401,1402,1403,1404,1405,1406,1407,1408,1409,1410,1411,1412,1413,1414,1415,1416,1417,1420,1437,1438,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1454,1458,1465,1466,1467,1469,1509,1511,1512,1513,1514,1515,1516,1546,1547,1549,1560,1561,1564,1565,1568,1569,1570,1571,1572,1574,1575,1576,1577,1578,1579,1581,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1615,1616,1618,1619,1623,1633,1634,1635,1636,1637,1638,1639,1641,1642,1643,1646,1647,1648,1649,1650,1669,1670,1671,1672,1673,1674,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1720,1721,1766,1767,1768,1769,1770,1771,1772,1774,1775,1778,1785,1791,1792,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1808,1810,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,1855,1856,1857,1860,1861,1862,1863,1864,1865,1866,1867,1868,1869,1870,1871,1872,1873,1874,1884,1913,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1941,1942,1943,1946,1951,1967,1971,1972,1973,1974,1975,1976,1977,1978,2006,2007,2008,2009,2010,2028,2031,2035,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055,2056,2064,2067,2068,2069,2070,2071,2074,2075,2076,2077,2078,2079,2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2093,2095,2096,2097,2098,2099,2100,2101,2102,2117,2120,2121,2122,2171,2172,2174,2175,2176,2177,2178,2179,2180,2181,2182,2183,2184,2185,2186,2187,2188,2189,2190,2191,2192,2193,2197,2198,2199,2200,2201,2202,2203,2204,2205,2206,2207,2208,2209,2210,2211,2212,2213,2234,2235,2236,2237,2238,2239,2240,2255,2256,2257,2258,2259,2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2274,2275,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,2290,2291,2292,2293,2294,2296,2297,2298,2300,2312,2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,2332,2333,2334,2335,2336,2337,2350,2354,2356,2357,2371,2375,2376,2377,2378,2379,2380,2392,2393,2394,2395,2396,2397,2398,2399,2401,2402,2403,2404,2405,2406,2407,2408,2409,2410,2411,2412,2413,2414,2415,2416,2417,2418,2419,2420,2421,2422,2426,2465,2466,2467,2468,2469,2470,2471,2472,2473,2489,2490,2503,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,2514,2515,2516,2517,2519,2520,2521,2522,2523,2524,2525,2526,2527,2528,2529,2530,2531,2532,2533,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2544,2545,2546,2547,2548,2549,2550,2551,2552,2553,2554,2555,2556,2557,2558,2559,2560,2561,2562,2632,2633,2634,2635,2636,2637,2638,2639,2641,2642,2643,2644,2645,2646,2647,2648,2649,2650,2651,2653,2654,2655,2656,2657,2658,2659,2660,2661,2662,2663,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,2677,2678,2679,2680,2682,2683,2684,2685,2686,2687,2688,2689,2690,2691,2692,2693,2694,2695,2696,2697,2698,2699,2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,2725,2726,2727,2728,2729,2730,2731,2732,2733,2734,2735,2736,2739,2740,2741,2742,2743,2744,2745,2746,2747,2748,2749,2750,2751,2752,2754,2755,2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2767,2770,2771,2772,2773,2774,2775,2778,2779,2780,2781,2782,2783,2784,2785,2786,2787,2788,2789,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,2800,2801,2802,2803,2807,2828,2852,2867,2868,2872,2874,2910,2911,2912,2913,2920,2928,2929,2930,2932,2933,2934,2935,2936,2937,2939,2940,2941,2942,2943,2946,2984,2985,2986,2989,2990,2998,2999,3002,3003,3006,3007,3010,3011,3012,3015,3016,3019,3020,3023,3027,3028,3029,3032,3033,3034,3037,3038,3039,3042,3043,3044,3080,3096,3097,3098,3101,3102,3103,3106,3107,3111,3112,3116,3117,3121,3122,3123,3128,3130,3131,3134,3135,3136,3137,3138,3156,3157,3158,3159,3160,3161,3162,3163,3164,3165,3166,3167) AND (`field_value-sendedatum`.`value` >= '2023-07-22 00:00:00' AND `field_value-sendedatum`.`value` < '2023-07-23 00:00:00') | 0.000    |

Ex. 2
SELECT `article`.`id` AS `article.id`
FROM `jsmwh_content` AS `article`
LEFT JOIN `jsmwh_fields` AS `field-sendedatum` ON `field-sendedatum`.`name` = 'sendedatum' AND `field-sendedatum`.`state` = 1 AND `field-sendedatum`.`context` = 'com_content.article'
LEFT JOIN `jsmwh_fields_values` AS `field_value-sendedatum` ON `field_value-sendedatum`.`field_id` = `field-sendedatum`.`id` AND `field_value-sendedatum`.`item_id` = article.id
WHERE `article`.`id` IN (102,105,106,107,108,111,113,117,120,122,127,129,131,134,138,140,143,145,147,150,192,194,197,200,203,205,207,214,215,216,235,236,255,315,317,318,319,320,383,413,414,415,416,417,420,470,471,475,476,477,478,579,580,581,583,584,585,586,587,588,627,628,629,631,632,634,675,676,677,700,701,704,705,706,707,727,728,729,730,731,734,735,736,737,738,741,742,743,744,745,746,911,913,914,915,917,918,920,921,922,923,924,925,927,928,929,930,931,934,935,936,937,938,941,999,1146,1194,1195,1196,1197,1200,1201,1202,1203,1204,1208,1209,1210,1211,1214,1215,1216,1217,1218,1221,1222,1223,1224,1225,1226,1227,1228,1229,1345,1438,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,1450,1451,1564,1568,1569,1570,1571,1572,1574,1575,1576,1577,1578,1579,1669,1670,1671,1672,1673,1674,1767,1768,1769,1770,1771,1772,1774,1775,1791,1792,1794,1795,1796,1797,1798,1799,1800,1810,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,2006,2007,2008,2009,2010,2067,2068,2069,2070,2071,2074,2075,2076,2077,2078,2079,2080,2172,2177,2178,2179,2180,2181,2182,2234,2235,2236,2237,2238,2239,2260,2261,2262,2263,2264,2265,2312,2313,2314,2315,2316,2317,2318,2319,2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2465,2466,2467,2468,2469,2470,2503,2504,2505,2506,2507,2508,2509,2641,2642,2643,2644,2645,2646,2647,2648,2649,2650,2651,2653,2654,2655,2656,2657,2658,2659,2660,2661,2662,2663,2664,2665,2666,2667,2668,2669,2670,2672,2673,2674,2675,2676,2677,2678,2679,2680,2928,2929,2930,2932,2933,2934,2935,2936,2937,2939,2940,2941,2942,2943,2946,3128,3131,3134,3135,3136,3137,3138,3156,3157,3158,3159,3160,3161,3162,3163,3164,3165,3166,3167) AND article.catid NOT IN (8,12,13,16,28,42,43,50,51,52,53,54,55,56,57,58,60,61,62,65,70,78,85,86,87,88,89,90,94,96,97,98,106,108,111,112,113,115,143,145,146,147,148,149,150,151,152,153,154,155,161,162,163,164,165,168,175,180,192)
ORDER BY `field_value-sendedatum`.`value` IS NULL, CAST(`field_value-sendedatum`.`value` AS CHAR(1)) = '', CAST(`field_value-sendedatum`.`value` AS CHAR(10)) = '0000-00-00', CAST(`field_value-sendedatum`.`value` AS SIGNED) DESC, `field_value-sendedatum`.`value` DESC LIMIT 6
Ex. 3
SELECT `article`.`id` AS `article.id`
FROM `jsmwh_content` AS `article`
LEFT JOIN `jsmwh_fields` AS `field-sendedatum` ON `field-sendedatum`.`name` = 'sendedatum' AND `field-sendedatum`.`state` = 1 AND `field-sendedatum`.`context` = 'com_content.article'
LEFT JOIN `jsmwh_fields_values` AS `field_value-sendedatum` ON `field_value-sendedatum`.`field_id` = `field-sendedatum`.`id` AND `field_value-sendedatum`.`item_id` = article.id
WHERE `article`.`id` IN (3016,3107,3163) AND article.catid NOT IN (8,12,13,16,28,42,43,50,51,52,53,54,55,56,57,58,60,61,62,65,70,78,85,86,87,88,89,90,94,96,97,98,106,108,111,112,113,115,143,145,146,147,148,149,150,151,152,153,154,155,161,162,163,164,165,168,175,180,192)
ORDER BY `field_value-sendedatum`.`value` IS NULL, CAST(`field_value-sendedatum`.`value` AS CHAR(1)) = '', CAST(`field_value-sendedatum`.`value` AS CHAR(10)) = '0000-00-00', CAST(`field_value-sendedatum`.`value` AS SIGNED) ASC, `field_value-sendedatum`.`value` ASC LIMIT 100
Peter van Westen's Avatar Peter van Westen ADMIN
You are probably using Articles Anywhere and outputting fields.
Articles Anywhere will have to query the database to get the values needed for the output.

If you have a lot of queries, it could be down to how you are using Articles Anywhere.
Please post a rating at the Joomla! Extensions Directory
Hitsch's Avatar Hitsch
Yes, that is correct, we use numerous fields and query their values. What would that mean? In this case, would ArticleAnywhere no longer be the tool of choice?
Peter van Westen's Avatar Peter van Westen ADMIN
Again, all down to how you are using it.
I would need to see actual examples.

Also, if queries are slow, it can be down to missing or incorrect indexes on your database tables.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription