Laravel expert needed to debug issue
Budget: ₹1,500 – ₹12,500 INR
We have an issue with a part of our Laravel project code.
We have a model called SentMessage and we have defined a relation called received_message_user (table: received_messages_users) on this model.
There is another model called ReceivedMessage (table: received_messages_users) on which we have defined additional_info and list_member relations.
For a particular id, let’s say 429189, we ran the following Laravel code. The time taken to execute it was around ~96 sec which is very huge. It tries to fetch 39,186 records along with the mentioned relations from the SentMessage model. The SQL queries are not taking much time but when they are written in the following manner they are taking very huge time. The following code can be written in Query builder but the issue is how to write ‘with’ functionality in query builder.
$sent = SentMessage::find($id);
$result = $sent
->received_message_user()->select('id', 'list_members_id', 'linked_sent_messages_id', 'read', 'read_snippet', 'date_received')
->with('additional_info:received_messages_table, message_id, online_notification_status, online_notification_sent_at, notification_delivered_at, online_notification_failure_reason')
->with('list_member:id,list_username')
->get();
We need to understand why the code is taking such an abnormal amount of time when the queries are taking fairly normal time.
Please get in touch / bid if you think you can fix the issue. Thank you.
We have a model called SentMessage and we have defined a relation called received_message_user (table: received_messages_users) on this model.
There is another model called ReceivedMessage (table: received_messages_users) on which we have defined additional_info and list_member relations.
For a particular id, let’s say 429189, we ran the following Laravel code. The time taken to execute it was around ~96 sec which is very huge. It tries to fetch 39,186 records along with the mentioned relations from the SentMessage model. The SQL queries are not taking much time but when they are written in the following manner they are taking very huge time. The following code can be written in Query builder but the issue is how to write ‘with’ functionality in query builder.
$sent = SentMessage::find($id);
$result = $sent
->received_message_user()->select('id', 'list_members_id', 'linked_sent_messages_id', 'read', 'read_snippet', 'date_received')
->with('additional_info:received_messages_table, message_id, online_notification_status, online_notification_sent_at, notification_delivered_at, online_notification_failure_reason')
->with('list_member:id,list_username')
->get();
We need to understand why the code is taking such an abnormal amount of time when the queries are taking fairly normal time.
Please get in touch / bid if you think you can fix the issue. Thank you.