我有這個疑問,其執行1或2秒爲一個給定的情況:多加入或子查詢的查詢優化
Select Count(*) as qtty
From event e
Join org o On o.orgID = e.orgID
Join venue v On v.venueID = e.venueID
Where Match(e.name, e.description) Against ($keywords)
And e.site_id = $site_id
And e.display <> 0</code>
它計算的行建立分頁。當我按事件類型過濾介紹(類型涉及多對多事件)查詢開始服用沒有少於45秒:
And Exists (
Select ete.id
From event_type_to_event ete
Where ete.event_id = e.eventID
And ete.event_type_id = $category)</code>
我也試圖與event_type_to_event一個加入,但它更慢。
有什麼建議嗎?
注:解決。使用索引,查詢執行時間縮短到不到一秒。
請貼EXPLAIN查詢 – 2009-10-06 13:00:05