I have two tables:
Business
Categories
Each business has a category and there are currently 10k+ businesses with different categories. I'm trying to find all of the businesses that have the category of 'Restaurant' using Laravel and MYSQL.
The code that I am using is below:
$businesses = Business::join('category', 'category.id', '=', 'businesses.category')
->where('category.name', '=', $cat)->get();
Which, when $cat
= 'Restaurant' brings back: 3183
results.
The issue is that at it's lowest, it's taking 8.9 seconds to 12 seconds to find any results. Can anyone suggest a way or where I'm going wrong which can improve how long this query takes to run?