Why doctrine does so many sql queries ? #6014

Closed
opened 2026-01-22 15:24:47 +01:00 by admin · 2 comments
Owner

Originally created by @niklass08 on GitHub (Jul 6, 2018).

Originally assigned to: @ostrolucky on GitHub.

Why doctrine does so many sql queries ?

Hello guys,

I'm new to doctrine and i'm working on an existing project that uses it. Im facing a performance issue : after fetching an entity from the database and doing some process on it's field I want to save it back. To do so I'm using the flush method. The issue is that in order to save the modification in the database doctrine does 4000+ queries including 3000+ delete and UPDATE to change the updated_at column on field that i didn't even modified. These 4000+ queries are taking up +3.5 sec. do you guys have any clue why doctrine does so much queries and why it is so long ?

Thank in advance for your answers !

Originally created by @niklass08 on GitHub (Jul 6, 2018). Originally assigned to: @ostrolucky on GitHub. Why doctrine does so many sql queries ? Hello guys, I'm new to doctrine and i'm working on an existing project that uses it. Im facing a performance issue : after fetching an entity from the database and doing some process on it's field I want to save it back. To do so I'm using the flush method. The issue is that in order to save the modification in the database doctrine does 4000+ queries including 3000+ delete and UPDATE to change the updated_at column on field that i didn't even modified. These 4000+ queries are taking up +3.5 sec. do you guys have any clue why doctrine does so much queries and why it is so long ? Thank in advance for your answers !
admin added the Invalid label 2026-01-22 15:24:47 +01:00
admin closed this issue 2026-01-22 15:24:47 +01:00
Author
Owner

@Ocramius commented on GitHub (Jul 6, 2018):

Sorry, on the road, so I can't browse for proper links, but you may need to:

  1. Read up on "the n+1 queries problem in ORMs
  2. Fetch joins in the doctrine-project.org website
  3. Read
    https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/

On Fri, 6 Jul 2018, 12:31 Nicolas BABEL, notifications@github.com wrote:

Why doctrine does so many sql queries ?
Version 2.5.5

Hello guys, I'm new to doctrine and i'm working on an existing project
that uses it. Im facing a performance issue : after fetching an entity from
the database and doing some process on it's field I want to save it back.
To do so I'm using the flush method. The issue is that in order to save the
modification in the database doctrine does 4000+ queries including 3000+
delete and UPDATE to change the updated_at column on field that i didn't
even modified. These 4000+ queries are taking up +3.5 sec. do you guys have
any clue why doctrine does so much queries and why it is so long ? Thank in
advance for your answers !


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7299, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakG_Eepy_vKdhMXyEWqoB1WbSpbhOks5uDzxlgaJpZM4VFPj0
.

@Ocramius commented on GitHub (Jul 6, 2018): Sorry, on the road, so I can't browse for proper links, but you may need to: 1. Read up on "the n+1 queries problem in ORMs 2. Fetch joins in the doctrine-project.org website 3. Read https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/ On Fri, 6 Jul 2018, 12:31 Nicolas BABEL, <notifications@github.com> wrote: > Why doctrine does so many sql queries ? > |------------ | ----- > | Version |2.5.5 > > Hello guys, I'm new to doctrine and i'm working on an existing project > that uses it. Im facing a performance issue : after fetching an entity from > the database and doing some process on it's field I want to save it back. > To do so I'm using the flush method. The issue is that in order to save the > modification in the database doctrine does 4000+ queries including 3000+ > delete and UPDATE to change the updated_at column on field that i didn't > even modified. These 4000+ queries are taking up +3.5 sec. do you guys have > any clue why doctrine does so much queries and why it is so long ? Thank in > advance for your answers ! > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7299>, or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakG_Eepy_vKdhMXyEWqoB1WbSpbhOks5uDzxlgaJpZM4VFPj0> > . >
Author
Owner

@ostrolucky commented on GitHub (Aug 2, 2018):

Unfortunately I have to close this, as this is not a support forum and this is not an actual issue. Try to use some of our community channels.

@ostrolucky commented on GitHub (Aug 2, 2018): Unfortunately I have to close this, as this is not a support forum and this is not an actual issue. Try to use some of our [community channels](https://www.doctrine-project.org/community/).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6014