exists 和 in 的區別

hql1:       delete Revision r where exists (select f from File f where f.fileState='2' and f.uid=r.file.uid)

等同於

hql2:      delete Revision r where r.uid in  (select f from File f where f.fileState='2' )

表Revision(小表),表File(大表) hql1效率高

Revision(大表),表File(小表) hql2效率低

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章