I have performance problem! I searched for Inner Join, tried optimize table but still the same. I have Users, Entries, Tags and tag_user tables.
This code works perfectly :
select * from `entries`
where (
select count(*) from `users` where `entries`.`profile_id` = `users`.`id`
) >= 1
order by `id` desc
And I should add this to complete my query :
select count(*) from `tags`
inner join `tag_user` on `tags`.`id` = `tag_user`.`tag_id`
where `tag_user`.`user_id` = `users`.`id` and `tags`.`id` in (?,?)) = 2
It becomes like this :
select * from `entries`
where (
select count(*) from `users`
where `entries`.`profile_id` = `users`.`id` and (
select count(*) from `tags`
inner join `tag_user` on `tags`.`id` = `tag_user`.`tag_id`
where `tag_user`.`user_id` = `users`.`id` and `tags`.`id` in (119,36)) = 2
) >= 1
order by `id` desc
Any solution for better performance ?