-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Massive performance issue with setParameter() and DateTime* objects #8113
Labels
Comments
For maintainers: seems like this should be marked as |
FYI, the root issue happens in doctrine/persistence, see doctrine/persistence#96 |
orocrmdeployer
pushed a commit
to oroinc/resource-library
that referenced
this issue
May 20, 2020
…data lookups (#27580) - to prevent the issue described in doctrine/orm#8113 Co-authored-by: Mykhailo Sulyma <[email protected]>
inri13666
pushed a commit
to oro-flex/batch-bundle
that referenced
this issue
Dec 28, 2021
…data lookups (#27579) - to prevent the issue described in doctrine/orm#8113
inri13666
pushed a commit
to oro-flex/message-queue-bundle
that referenced
this issue
Jan 6, 2022
…data lookups (#27579) - to prevent the issue described in doctrine/orm#8113
jenkins-oroinc-app bot
pushed a commit
to oroinc/resource-library
that referenced
this issue
Jan 10, 2022
…data lookups (#27579) - to prevent the issue described in doctrine/orm#8113
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Related doc PR to warn users: #8114
Summary
Using
$qb->setParameter('date', new \DateTimeImmutable())
without specifying 3rd argument (the type) leads to massive performance issues in long running processes.This is a follow up for #7527 (originally posted here #7471 (comment))
Current behavior
As it's stated in the official docs (binding parameters to query)
So you can just pass a datetime object and it will work:
However, this leads to a) search this metadata in a cache, it fails and then b) load class metadata for every parameter of date types (e.g.
\DateTimeImmutable
), and such metadata does not exist of course.Performance impact
We have a consumer that continuously reads data from the queue and executes queries, passing datetime object to
setParameter()
.Consumer is able to handle ~250 messages per secong, producing thousands of queries per second when it is fresh / is just started.
However, after some time there is a massive performance degradation (from 250/s, 230/s, ... 100/s, ... and so on). And this is exactly because of all the code that is executed just to load metadata for
\DateTimeImmutable
class which never exist).So there are thousands of cache misses, thrown but caught exceptions, attempts to load metadata.
After changing this
to this
we are no longer experiencing performance issues. After 30 minutes of working, consumer still handles ~250 records per second without degradation.
How to reproduce
Just create any entity with
datetime
/datetime_immutable
mapped property.Expected behavior
Expected behavior would be to not try loading metadata for datetime objects, but return the type immediately somewhere here:
orm/lib/Doctrine/ORM/Query.php
Lines 411 to 413 in 8c259ea
before trying to load metadata.
At this point,
$parameter
already havedatetime
type inside:The text was updated successfully, but these errors were encountered: