嗨朋友有誰能告訴我什麼是我的查詢問題。當我執行時,它將數據庫鎖定5到10分鐘,請幫助我優化此查詢。如何在執行查詢時解決數據庫鎖定問題
SELECT
u.username,
u.email,
u.created_at,
p.firstname,
p.lastname,
p.address,
p.address_2,
p.city,
p.country,
p.state,
p.zip,
p.phone,
p.phone_2,
u.last_ip,
u.last_login_at,
u.auto_login,
u.registration_page,
s.product_name
FROM
users AS u
Left Join subscriptions AS s ON u.id = s.user_id
Left Join profiles AS p ON u.id = p.user_id
where u.registration_page='Chris_Cleanse' and
u.id not in (select user_id from goal_sheets) and
u.id not in(select user_id from sheet_user_popup_not_adam) and
s.expired=TRUE ORDER BY u.id DESC;
這個問題更適合http://dba.stackexchange.com/或http://codereview.stackexchange.com/ –
你能發佈'EXPLAIN SELECT u.username,...'的輸出(解釋你的查詢)? –
@D。 Kasipovic在這裏是輸出http://i.imgur.com/R1PYdeI.png – Haseeb