1

I built a site several years ago with 3 statuses so editors could position articles on a category landing page. I coded some of the entry tags like this to ensure that adding additional statuses wouldn't affect the results unless I explicitly revised the parameter settings.

status="Open|Mini Feature|Main and Mini Feature|Main Feature"

Well, no additional statuses have ever been added and I want to make sure my queries are as efficient as possible. This is a high traffic site.


My question is... which produces a more efficient query?

status="Open|Mini Feature|Main and Mini Feature|Main Feature"

OR

status="not closed"
2

status="not closed" will be more efficient. When the Channel module is building its SQL query, it checks to see if there's more than one status being asked for. If it's one status, it uses WHERE status =. If it's more than one status, then it'll use WHERE status IN. = is more efficient than IN.

0

I'd say because the way MySQL works, the latter is more efficient. You're basically saying, in SQL:

SELECT entries FROM channel WHERE status IS NOT closed

vs. saying:

SELECT entries FROM channel WHERE status IS open OR Mini Feature OR Main AND Mini Feature OR Main Feature

as a machine reading these queries, the first is much more concise, and will also be more concise in your template :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.