Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends,

I have query below. it executes 24 seconds.. how to reduce the execution time..

SQL
SELECT CONCAT(
    'SELECT `chef_orders_pending_temp`.item_id,`chef_orders_pending_temp`.itemName,`chef_orders_pending_temp`.order_date', GROUP_CONCAT('
     ,    `t_', REPLACE(Outlet_name, '`', '``'), '`.QtyRequested
         AS `', REPLACE(Outlet_name, '`', '``'), '`'
     SEPARATOR ''),
 ' FROM `chef_orders_pending_temp` ', GROUP_CONCAT('
     LEFT JOIN `chef_orders_pending_temp`   AS `t_', REPLACE(Outlet_name, '`', '``'), '`
            ON `chef_orders_pending_temp`.item_id = `t_', REPLACE(Outlet_name, '`', '``'), '`.item_id
           AND `t_', REPLACE(Outlet_name, '`', '``'), '`.Outlet_name = ', QUOTE(Outlet_name)
     SEPARATOR ''),
 ' GROUP BY `chef_orders_pending_temp`.item_id'
) INTO @qry FROM (SELECT DISTINCT Outlet_name FROM `chef_orders_pending_temp`) t;

PREPARE stmt FROM @qry;

EXECUTE stmt;
Posted
Updated 1-Feb-16 18:22pm
v2
Comments
Vivek.anand34 2-Feb-16 1:46am    
i have reduced fields in 'chef_orders_pending_temp' view to what i need. Now reduced execution time...
Herman<T>.Instance 2-Feb-16 3:54am    
solved?
Vivek.anand34 3-Feb-16 7:11am    
Ya it solved now...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900