elby's avatar
Level 1

Laravel Eloquent issue with Mysql 8 | Laravel duplicate prepare statement

Laravel Eloquent query triggering duplicate prepare statement in Mysql 8.x Mysql General logs. For Example User::find(10); is triggering two prepare statement and one execute query in Mysql. But Mysql 5.x is working fine.

2023-07-21T08:27:06.028226Z 366 Prepare select * from users where users.id = ? and users.deleted_at is null limit 1 2023-07-21T08:27:06.028488Z 366 Prepare select * from users where users.id = ? and users.deleted_at is null limit 1 2023-07-21T08:27:06.028527Z 366 Execute select * from users where users.id = 17 and users.deleted_at is null limit 1

0 likes
2 replies
MohamedTammam's avatar

Mostly, one is for you query and the other is for Laravel authentication middleware to get the authenticated user.

elby's avatar
Level 1

@MohamedTammam No.. other queries also same. I ran with tinker and other system and projects.

2023-07-21T08:50:08.253051Z 374 Prepare select * from permission_temp where organization_id = ? and permission_id = ? limit 1 2023-07-21T08:50:08.253148Z 374 Prepare select * from permission_temp where organization_id = ? and permission_id = ? limit 1 2023-07-21T08:50:08.253169Z 374 Execute select * from permission_temp where organization_id = 6999 and permission_id = 108789797 limit

Please or to participate in this conversation.