Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent
Last updated 2 years ago.
0

Show us what

explain select * from `posts` where (select count(*) from `categories` inner join `post_categories` on `categories`.`id` = `post_categories`.`category_id` where `post_categories`.`post_id` = `posts`.`id` and `name` = '大標題' order by `categories`.`id` asc) >= '1' and `published_at` = '2014-03-18'

gives you.

You are most likely missing indexes.

  • posts table should have one index for published_at.
  • categories should have an index for name.
  • post_categories should have two foreign keys, first on post_id matching posts.id, second on category_id matching categories.id.
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

alainbelez alainbelez Joined 11 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.