Skip to content
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

Make reserve faster on DbQueue #281

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mikk150
Copy link

@mikk150 mikk150 commented Oct 24, 2018

Q A
Is bugfix? yes
New feature? no
Breaks BC? no
Tests pass? yes
Fixed issues #280

@mikk150
Copy link
Author

mikk150 commented Oct 25, 2018

Mkay, this does not fix it... it makes it better, but ultimately it is still slow

Because of ORDER BY clause, it does not use index for some reason even if I add all fields that are used in ORDER BY or WHERE clause.. but I found out that when I change LIMIT 1 to LIMIT 100 it is fast for some bizarre reason(I literally have no idea why it does that)...

so, should I remove this LIMIT 1 and replace it with LIMIT 100 and rely on the fact that one()

@samdark
Copy link
Member

samdark commented Oct 25, 2018

That's super-weird. How could it be that selecting 1 record is slower than selecting 100 records?

@mikk150
Copy link
Author

mikk150 commented Oct 25, 2018

@samdark my findings there even were wrong. I am still trying to figure out how to make it so that it starts using indexes

screenshot from 2018-10-25 12-35-44

@samdark
Copy link
Member

samdark commented Oct 25, 2018

It won't use index since it doesn't make sense to use index on two rows. Even full table scan will be faster.

@samdark
Copy link
Member

samdark commented Oct 25, 2018

Make it 5000 rows and check again.

@mikk150
Copy link
Author

mikk150 commented Oct 25, 2018

That is not the case..
If I remove order by clause then it is fast
screenshot from 2018-10-25 19-36-42

@samdark samdark added the type:bug Bug label Oct 25, 2018
@rob006
Copy link

rob006 commented Oct 26, 2018

I played with this some time ago and I've got much better performance with separate query for each priority (I have 3 priorities, so it was not a big deal) than one query with ORDER BY priority.

@mikk150
Copy link
Author

mikk150 commented Oct 26, 2018

@rob006 unfortunately yii2-queue supports more than 3 priorities... I would like to fix it once and for all, just as it should be fixed

@rob006
Copy link

rob006 commented Oct 26, 2018

unfortunately yii2-queue supports more than 3 priorities...

That depends on driver. Some of them support more priorities, some of them does not support priorities at all. There is no standard here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants