我正在考慮在(1)中創建散列索引,因爲它使用(2)上的等式和位圖,因爲狀態只能被「接受」或「不被接受」。我還能使用什麼?也是我的問題是,我只能儘量在MySQL的Oracle B樹索引..我應該創建哪些類型的索引來優化這些mysql查詢?
(1)select R.user_id from rent as R
inner join supervise S on
R.adress = S.adress
and R.space_id = S.space_id
group by R.user_id
having count(distinct S.supervisor_id) = 1
(2) select distinct P.adress, P.code from space as P where (P.adress, P.code) not in (
select P.adress, P.code from space as P
natural join rent as R
natural join state as E where E.state = ‘accepted’)
爲什麼你的代碼中有['零寬度空間'(U + 200B)](http://www.fileformat.info/info/unicode/char/200b/index.htm)字符? ---爲什麼你的文字使用時髦的撇號(''和''',而不是''')? – Andreas