假设我有下面的SQL
如何优化查询的性能?
select product, address, quantity,
price, create_date, sum(no_of_photo) as no_of_photo
from
(
SELECT customer.PROJECT_ID as project_id ,
customer.ORDER_TYPE as order_type,
customer.product_name as product,
customer.address_name as address ,
customer.quantity_name as quantity,
user.first_name || ' ' || user.last_name AS price,
customer.create_date, customer.no_of_photo
FROM customer
INNER JOIN user
ON customer.creation_userid = user.userid
) master_list
group by project_id, order_type ,
product, address, quantity, price,
create_date
having project_id = 123456
order by product, address, quantity, price, create_date
答案 0 :(得分:4)
我会尝试一些事情:
还要确保有以下索引:
答案 1 :(得分:1)
通常通过创建索引来实现最佳增长。你询问内部联接。没有内部联接,它会快吗?那么你可能需要user.userid上的索引。