Nisha Patel
Problem
I have a Laravel query builder query which is taking more than 20 seconds to retrieve ~2500 records. Ideally, it should take much less time. I think the orOn join in my query is what is causing this issue. Am not able to figure out how can I optimize this query to execute much more quickly
Please let me know if anyone can help with this.
Solution
I think for this you can use eager loading for all of these leftjoins you can define relationship functions inside the customer module.
I think you should treat them as separate relationships and call themes like these.
Customer::with('getActiveFeedback1','getActiveFeedback2','getActiveFeedback3','getFeedbackRequestStatus','getCustomerService','getbusinesslocation')->where('is_active',1)->orderBy('created_at','DESC')->groupBy('id')->get();
Answered by: >Ankit Shekhawat
Credit: >StackOverflow
Blog Links:
>How to manage the Text in the container in Django?
>Fix webapp stops working issue in Django- Python webapp
>Creating a form in Django to upload a picture from the website
>Sending Audio file from Django to Vue
>How to keep all query parameters intact when changing page in Django?
>Solved: TaskList View in Django
>Implement nested serializers in the Django rest framework
>How to filter events by month in Django?
>Sorting the restframework in Django
>Ways to access instances of models in view in order to save both forms at once in Django
>What makes index.html have such kind of name in Django?
>Fix Module Not Found during Deployment- Django
>Creating a Django with existing directories, files, etc.?
>How to Read a CSV file with PHP using cURL?