Re: Very long query doubt... (Monster query...)
Posted by:
Toni Lopez
Date: March 30, 2009 09:04AM
Explain results:
I wil put some of them, so you can see one sample for each type, talking always about sizes...
-Smallest:
select sum(cantidad),sum(precio),sum(dto * precio) from prepara_sales_mix where fecha >= '2008-09-01' and fecha <= '2008-09-30' and cod_serie in (2, 7, 14, 17, 22, 28, 35, 44, 48, 58, 62, 65, 70, 71, 73, 84, 87, 91, 95, 96, 115, 121, 124, 130, 137, 138, 139, 142, 143, 144, 145, 146, 147, 149, 150, 153, 154, 156, 157, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 174, 175, 177, 179, 180, 182, 183, 184, 186, 187, 188, 189, 190, 191, 192, 195, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 210, 212, 213, 214, 216, 218, 219, 220, 222, 223, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 236, 237, 238, 239, 240, 241, 243, 244, 245, 246, 247, 248, 249, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 266, 267, 268, 271, 273, 274, 276, 277, 279, 280, 281, 282, 284, 285, 289, 290, 292, 294, 295, 299, 300, 301, 302, 303, 304, 306, 307, 308, 309, 311, 312, 313, 314, 315, 316, 317, 318, 319, 321, 322, 324, 325, 326, 327, 328, 330, 332, 333, 334, 335, 336, 337, 338, 340, 341, 342, 343, 344, 345, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 361, 362, 363, 364, 365, 366, 367, 368, 369, 897, 899) and ( (cod_articulo = 'TL102' and clase = 'C') or (cod_articulo = 'TL102' and clase = 'N') or (cod_articulo = 'TL106' and clase = 'N') or (cod_articulo = 'TM000' and clase = 'C') or (cod_articulo = 'TM000' and clase = 'N') or (cod_articulo = 'TM01' and clase = 'C') or (cod_articulo = 'TM01' and clase = 'N') or (cod_articulo = 'TM210' and clase = 'C') or (cod_articulo = 'TM210' and clase = 'N') or (cod_articulo = 'TST11' and clase = 'C') or (cod_articulo = 'TST11' and clase = 'H') or (cod_articulo = 'TST11' and clase = 'N') or (cod_articulo = 'TST11B' and clase = 'C') or (cod_articulo = 'TST11B' and clase = 'N') or (cod_articulo = 'TST11B' and clase = 'S') or (cod_articulo = 'TST11BL' and clase = 'C') or (cod_articulo = 'TST11BL' and clase = 'N') or (cod_articulo = 'TST12SL' and clase = 'C') or (cod_articulo = 'TST12SL' and clase = 'N') or (cod_articulo = 'TST13BL' and clase = 'C') or (cod_articulo = 'TST13BL' and clase = 'N') or (cod_articulo = 'TST15' and clase = 'C') or (cod_articulo = 'TST15' and clase = 'M') or (cod_articulo = 'TST15' and clase = 'N') or (cod_articulo = 'TST15' and clase = 'S') or (cod_articulo = 'TST15B' and clase = 'C') or (cod_articulo = 'TST15B' and clase = 'N') or (cod_articulo = 'TST15BL' and clase = 'C') or (cod_articulo = 'TST15BL' and clase = 'N') or (cod_articulo = 'TST18BSL' and clase = 'C') or (cod_articulo = 'TST18BSL' and clase = 'N') or (cod_articulo = 'TST18SL' and clase = 'C') or (cod_articulo = 'TST18SL' and clase = 'M') or (cod_articulo = 'TST18SL' and clase = 'N') or (cod_articulo = 'TST9B' and clase = 'N') or (cod_articulo = 'TB503' and clase = 'C') or (cod_articulo = 'TB503' and clase = 'N') or (cod_articulo = 'TTMACLA' and clase = 'C') or (cod_articulo = 'TTMACLA' and clase = 'N') )
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE prepara_sales_mix range fecha fecha 3 NULL 317504 Using where
(No use of index ... why?)
-------------