We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Performance issue? | Forum

Marcus
Marcus Sep 2 '20

Its been quite some time since I tried to find a way to speed this query up which slows db big time and if u combine it with group by then just grab a chair kick back and maybe even grab a soda or something case its gonna take ages lol.



INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = someId

LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id`

WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1)


I have tried adding index to both of them but no joy!


I try to avoid this query as much as I can but its so essential you just gotta use it!


Any inputs on this issue will be hugely appreciated.



Here i try to organize users by friends count and OMG its slow!



SELECT f.`userId`,count(f.`userId`)as score

FROM `ow_friends_friendship` f

INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = f.`friendId`

LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id`

WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) and  f.`status` = 'active'



GROUP BY f.userId ORDER BY count(f.`userId`) DESC


Now u get rid of all those inner and left joins its quite fast!

The Forum post is edited by Marcus Sep 2 '20
Marcus
Marcus Sep 2 '20

The query above takes 0.5 sec now by using temp table takes 0.002 sec huge improvement why not sure???


CREATE TEMPORARY TABLE tempTable1
    as (SELECT f.`userId`,count(f.`userId`)as score

FROM `ow_friends_friendship` f

INNER JOIN `ow_base_user` base_user_table_alias ON base_user_table_alias.`id` = f.`friendId`

LEFT JOIN `ow_base_user_suspend` base_user_suspend_table_alias ON base_user_suspend_table_alias.`userId` = `base_user_table_alias`.`id`

WHERE (`base_user_suspend_table_alias`.`id` IS NULL) AND (`base_user_table_alias`.`emailVerify` = 1) and  f.`status` = 'active'



GROUP BY f.userId ORDER BY count(f.`userId`) DESC);


select * from tempTable1

The Forum post is edited by Marcus Sep 2 '20
dave Leader
dave Sep 7 '20
INNER joins are well known for being very slow.  The temp table is probably just a better use of the resources is all.  That would be my guess.
beyondherd
beyondherd Oct 4 '23
I am facing the performance issue with my webpage computer chair neck support. Let me know if anyone can help me out. Thanks
anna
anna Dec 11 '23
An extremely helpful essay! This post contains a wealth of information about the that may help anyone launch a successful social media campaign. word wipe
REHMAN
REHMAN Dec 12 '23

A lot of thanks for your whole efforts on this web site. Kate really loves doing investigations and it’s easy to understand why. My spouse and i hear all of the powerful means you give useful strategies via your web site and even improve response from visitors on the idea while our girl is becoming educated a lot of things. Take advantage of the remaining portion of the new year. You’re the one conducting a useful job.

jun88


REHMAN
REHMAN Dec 15 '23

I would like to thank you for the efforts you have put in writing this Magic Mesh Door Coverblog. I’m hoping the same high-grade blog post from you in the future also. Actually your creative writing abilities has inspired me to get my own screen door instant website going now. Actually blogging is spreading its wings and growing fast. Your write up is a great example.

Rút tiền nổ hũ


REHMAN
REHMAN Dec 18 '23

Greetings! This is my first visit to your blog! We are a collection of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done a marvellous job!

un curso de milagros


REHMAN
REHMAN Dec 26 '23

Pretty section of content. I just stumbled upon your blog and in accession capital to assert that I acquire actually enjoyed account your blog posts. Anyway I’ll be subscribing to your augment and even I achievement you access consistently fast.

RÚT TIỀN 789WIN


REHMAN
REHMAN Jan 2

Well worded post will be sharing this with my readers this evening

kèo trực tuyến


REHMAN
REHMAN Jan 5

It is a great website.. The Design looks very good.. Keep working like that!.

借錢