我将几个表格加入到一个视图中,以便于编码。现在,当我使用该视图加入几个表时,我的性能很差。当我看到更多行时,这些查询的速度显着降低。我使用这个视图写了很多代码,所以我不喜欢重写所有这些查询的解决方案:)。当我将它与其他表连接时,是否有任何优雅的解决方案来加速这个视图?
这是我的查询之一,tickets_parsed
视图在哪里:
SELECT detailValue, SUM(total_tickets) AS total_tickets, SUM(money_in) AS money_in, SUM(handling_charges) AS handling_charges
FROM (
SELECT bsid, COUNT(*) AS total_tickets, SUM(amount_total) AS money_in, SUM(handling_charges) AS handling_charges
FROM `bingo`.tickets_parsed
WHERE tickettime BETWEEN '$date' AND '$date2a'
AND ticketstatus <> 'CLOSED'
GROUP BY bsid
ORDER BY NULL
) AS sub
NATURAL JOIN betshop_details
WHERE detailID = 5
GROUP BY detailValue
ORDER BY NULL