Оптимизировать условие в VIEW
Добавлено: 27 мар 2007, 10:19
Есть вьюшка в ней условие.
Where
( ( createuserid = (select id from username where name = current_user ))
OR (touserid = (select id from username where name = current_user )))
or (exists (select 1 from username where name = current_user and read_other = 1))
or ( touserid = 0)
or (togroupid = (select usertogroup.groupid from username, usertogroup where name = current_user
and username.id = usertogroup.userid))
как можно оптимизировать?
пробовал вот так
ничего не поменялось
( (createuserid = (select id from username where name = current_user ))
OR (touserid IN( (select id from username where name = current_user ), 0)))
or (exists (select 1 from username where name = current_user and read_other = 1))
-- or (touserid = 0)
or (togroupid = (select usertogroup.groupid from username, usertogroup where name = current_user
and username.id = usertogroup.userid))
Where
( ( createuserid = (select id from username where name = current_user ))
OR (touserid = (select id from username where name = current_user )))
or (exists (select 1 from username where name = current_user and read_other = 1))
or ( touserid = 0)
or (togroupid = (select usertogroup.groupid from username, usertogroup where name = current_user
and username.id = usertogroup.userid))
как можно оптимизировать?
пробовал вот так
ничего не поменялось
( (createuserid = (select id from username where name = current_user ))
OR (touserid IN( (select id from username where name = current_user ), 0)))
or (exists (select 1 from username where name = current_user and read_other = 1))
-- or (touserid = 0)
or (togroupid = (select usertogroup.groupid from username, usertogroup where name = current_user
and username.id = usertogroup.userid))