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

Inefficient queries #15

Closed
svivian opened this issue Feb 11, 2016 · 1 comment
Closed

Inefficient queries #15

svivian opened this issue Feb 11, 2016 · 1 comment

Comments

@svivian
Copy link

svivian commented Feb 11, 2016

Hi Ami, I've just been looking at a few plugins to see how fast they are. This one does seem pretty good for speed, but I did notice one issue here: https://github.com/amiyasahu/q2a-breadcrumbs/blob/master/inc/Ami_Breadcrumb.php#L126

You are running SQL queries inside a loop so with nested categories I end up with 4 queries:

SELECT categoryid, parentid, title, tags, qcount, content, backpath FROM qa_categories WHERE tags='parentcategory'
SELECT categoryid, parentid, title, tags, qcount, content, backpath FROM qa_categories WHERE tags='cat2'
SELECT categoryid, parentid, title, tags, qcount, content, backpath FROM qa_categories WHERE tags='cat3'
SELECT categoryid, parentid, title, tags, qcount, content, backpath FROM qa_categories WHERE tags='cat4'

This could be replaced with a single query like this:

SELECT categoryid, parentid, title, tags, qcount, content, backpath FROM qa_categories WHERE tags IN ('parentcategory', 'cat2', 'cat3', 'cat4')

And then loop through the results to get the info you need. Hope that helps :)

@amiyasahu
Copy link
Owner

@svivian , Thank you for reporting the issue. I will fix it this weekend.

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

No branches or pull requests

2 participants