I am lack of knowledge to know how can I possible improve this
So was hoping fellow perl monks can point me into the direction so I can get a start from there.this script is used to find the first decreased price, will get 1.67 in this case to insert to db.
i got multiple tables in database, fruit_load , fruit_pricing country zipcode city name mgroup subgroup fruit special_fruit fruit_price special_fruit_price To get the pricing for each fruit in each group in each city, zipcodeand country, I do multiple while loops,3.88 1.67 1.53 1.52 + - -
Let meknow if I can provide more information, I can give the whole code, but I try to makeit short and sweet.SELECT DISTINCT (country, zipcode, city) FROM fruit_load WHERE fruit_l +oad.sold_date BETWEEN NOW() - INTERVAL 60 DAY AND NOW(); SELECT DISTINCT (owner) FROM fruit_pricing b JOIN fruit_load a ON a.fr +uit_load_id = b.fruit_load_id WHERE a.country= '$data[0]' AND a.zipco +de = '$data[1]' AND a.city = '$data[2]'; SELECT DISTINCT (mgroup) FROM fruit_pricing b JOIN fruit_load a ON a.f +ruit_load_id = b.fruit_load_id WHERE a.country = '$data[0]' AND a.zip +code = '$data[1]' AND a.city = '$data[2]' AND b.owner ='$data2[0]'; SELECT DISTINCT (fruit) FROM fruit_pricing b JOIN fruit_load a ON a. f +ruit_load_id = b. fruit_load_id WHERE a.country = '$data[0]' AND a.zi +pcode = '$data[1]' AND a.city = '$data[2]' AND b.owner = '$data2[0]' +AND b.mgroup = '$data3[0]'; SELECT * FROM fruit_load a JOIN fruit_pricing b ON a.fruit_load_id = b.fruit_load_id WHERE b.sold_date BETWEEN NOW() - INTERVAL 180 DAY AND NOW() AND a.country = '$data[0]' AND a.zipcode = '$data[1]' AND a.city = '$data[2]' AND b.owner = '$data2[0]' AND b.mgroup = '$data3[0]' AND b.fruit = '$data4[0]' ORDER BY sold_date DESC; put found row into array in this loop SELECT DISTINCT (subgroup) FROM special_fruit_price c JOIN fruit_load +a ON a.fruit_load_id = c.fruit_load_id WHERE a.country = '$data[0]' A +ND a.zipcode = '$data[1]' AND a.city = '$data[2]' AND c.owner = '$dat +a2[0]'; SELECT DISTINCT (special_fruit) FROM special_fruit_price c JOIN fruit_load a ON a.fruit_load_id = c.fruit_load_id WHERE a.country = '$data[0]' AND a.zipcode = '$data[1]' AND a.city = ' +$data[2]' AND c.owner = '$data2[0]' AND c.mgroup = '$data3[0]' AND c.subgroup = '$data6[0]'; SELECT * FROM fruit_load a JOIN special_fruit_price c ON a.fruit_load_id = c.fruit_load_id WHERE c.sold_date BETWEEN NOW() - INTERVAL 180 DAY AND NOW() AND a.country = '$data[0]' AND a.zipcode = '$data[1]' AND a.city = '$data[2]' AND c.owner = '$data2[0]' AND c.mgroup = '$data3[0]' AND c.subgroup = '$data6[0]' AND c.special_fruit = '$data7[0]' ORDER BY sold_date DESC; put found row into array in this loop
The code currently run 15 mins to 2 hours varies, is it possible to shorten the time ?
I believe the multiple insert will slow down the process, at current I am trying to put them into array and insert at once.| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |