0
SELECT distinct
    *
    FROM

    dictionary d  
    join dictionary_with_word dw on dw.dictionary_id=d.dictionary_id  
    join word w on w.word_id=dw.word_id  
    join word_day wd on  wd.word_id=w.word_id  
    join have_buy_dictionary hbd on hbd.have_buy_dictionary_dictionary=d.dictionary_id

    where wd.user_id=777 and wd.word_day=0 

我用上面的sql查询很快。

但是当我在上面的 sql 语句的末尾添加 sql 代码“and d.dictionary_id=9”时:

SELECT distinct
    *
    FROM

    dictionary d  
    join dictionary_with_word dw on dw.dictionary_id=d.dictionary_id  
    join word w on w.word_id=dw.word_id  
    join word_day wd on  wd.word_id=w.word_id  
    join have_buy_dictionary hbd on hbd.have_buy_dictionary_dictionary=d.dictionary_id

    where wd.user_id=777 and wd.word_day=0 
    and d.dictionary_id=9

然后会很慢!

为什么 ?

4

0 回答 0