-
Notifications
You must be signed in to change notification settings - Fork 2
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
Count Performance of DoctrineORMAdapter COUNT query and large record sets #115
Comments
+1 |
Well it looks like there is a quick fix.
Still I think this is error to use complex query by default. |
I think this commit solved this issue.
|
I'd agree this looks to be resolved |
Closing then. |
@afterdesign where did you get the |
To clearify: If your code looks something like this: $pagerfanta = new Pagerfanta(new DoctrineORMAdapter($query)); You'll want to change it to something like this (to make use of the commit mentioned above): $pagerfanta = new Pagerfanta(new DoctrineORMAdapter($query, true, false)); |
@nmeirik I've added the |
@loostro To me it sounds like your query might be too complex to benefit from the simplified count. But this is slightly over my head, so hopefully someone else can shed a better light on this. |
I'm also having mixed results with the simplified count option (number of bound variables does not match number of tokens). Is there a way we can set a hint, like KnpLabs/KnpPaginatorBundle#27 (comment) |
@loostro can you show the DQL query you are trying to paginate ? |
@stof I don't remember the exact query now (I had to workaround this), but I can describe what caused my problems. My entities/*
* @ORM\Table(name="contract")
* @ORM\InheritanceType("JOINED")
* @ORM\DiscriminatorColumn(name="discr", type="string")
*/
abstract class Contract {}
/* Not mapped */
abstract class DonationContract extends Contract {}
/*
* @ORM\Entity()
* @ORM\Table(name="contract_donation_in_money")
*/
class DonationInMoneyContract extends DonationContract {}
/**
* @ORM\Entity()
* @ORM\Table(name="contract_donation_in_kind")
*/
class DonationInKindContract extends DonationContract {}
/* Not mapped */
abstract class SpecifiedTaskContract extends Contract {}
/**
* @ORM\Entity()
* @ORM\Table(name="contract_specified_task_with_natural_person")
*/
class SpecifiedTaskWithNaturalPersonContract extends SpecifiedTaskContract {}
/**
* @ORM\Entity()
* @ORM\Table(name="contract_specified_task_with_company")
*/
class SpecifiedTaskWithCompanyContract extends SpecifiedTaskContract {} The table I was querying was |
Due to overload, we disabled output walkers (see whiteoctober/Pagerfanta#115
Due to overload, we disabled output walkers (see whiteoctober/Pagerfanta#115
This issue is pertinent to Pagerfanta\Adapter\DoctrineORMAdapter.
I've run into performance problems with the way that the 'count' part of the pagination query is being constructed as referenced in the following issues (across multiple projects) (using MySQL):
KnpLabs/knp-components#77
doctrine/orm#298
KnpLabs/knp-components#65
KnpLabs/KnpPaginatorBundle#202
beberlei/DoctrineExtensions#59
This issue will be relevant to anyone using the paginator with MySQL and anything approaching a large number of rows in a database (for me 80k) - when it can take > 100 seconds to execute the count part of the query on a modest amount of data.
My goal here is to simplify the poorly performing query being generated, given that I'm not performing any join or group conditions (and I appreciate why the below structure may be required if this were the case), I have no need for either the 'distinct' subquery, nor the inner subquery it selects from. I'm trying to get from this:
to this:
or this (I don't care about the DISTINCT as it doesn't seem to hurt performance):
It seems the way to do this is to avoid using the 'Doctrine\ORM\Tools\Pagination\CountOutputWalker' within the Doctrine paginator.
I've tried a variety of changing query walkers, query hints, and changing options in the paginator, and I've found I can achieve what I want by doing this in the DoctrineORMAdapter constructor:
So:
Could/Should the option to disable use of output walker be available in the adapter constructor:
OR is there an alternative way to get this behaviour (such as setting a hint on the query before passing it to the adapter) that I've missed.
The text was updated successfully, but these errors were encountered: