我想了解您对以下查询的想法:
select a.expense_code, a.expense_date, a.expense_supplier_code, b.supplier_name, a.expense_discount, a.expense_payment_method, a.expense_payment_transfer_to, a.expense_advance, a.expense_status,
sum(c.expense_item_buy_price * c.expense_item_quantity) , d.account_name, a.expense_counter, a.expense_type, a.expense_saving_type, a.expense_payment_transfer_from
from expense_data a, supplier_data b, expense_item c, tree_data d
where a.expense_supplier_code = b.supplier_code and a.expense_payment_transfer_to= d.account_code
and a.expense_counter = c.expense_counter
and a.expense_date between '2013-01-01' and '2014-01-01' and a.expense_status = 0 or a.expense_status = 2 group by (a.expense_counter);
即使在费用数据表中有四个索引,此查询也花费了很多时间:
1- Expense_code.
2- expense_user_id
3- expense_supplier_code
4- expense_payment_transfer_from
我不知道为什么要花这么多时间,是因为两个人的加入,还是因为太多的indeces。你能建议吗?