select
k.*,
(select count(*) from kkutu_ko k2 where left(k2._id, 1) = right(k._id, 1)) as cnt
from kkutu_ko k
WHERE
_id like 'a%'
AND
type ~ '(^|,)(0|1|3|7|8|11|9|16|15|17|2|18|20|26|19|INJEONG)($|,)'
AND
LENGTH(_id) > 1
LIMIT 100;
kkutu_ko中的431399行。
由于count(*)
和type ~ blabla
,我觉得它很慢。
如何优化此查询?