yii2-queue icon indicating copy to clipboard operation
yii2-queue copied to clipboard

Make reserve faster on DbQueue

Open mikk150 opened this issue 5 years ago • 9 comments

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

mikk150 avatar Oct 24 '18 12:10 mikk150

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()

mikk150 avatar Oct 25 '18 08:10 mikk150

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

samdark avatar Oct 25 '18 16:10 samdark

@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

mikk150 avatar Oct 25 '18 16:10 mikk150

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 avatar Oct 25 '18 16:10 samdark

Make it 5000 rows and check again.

samdark avatar Oct 25 '18 16:10 samdark

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

mikk150 avatar Oct 25 '18 16:10 mikk150

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.

rob006 avatar Oct 26 '18 08:10 rob006

@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

mikk150 avatar Oct 26 '18 09:10 mikk150

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.

rob006 avatar Oct 26 '18 11:10 rob006