-1

If I'm checking for a certain variable for each post in the loop, is it less DB intensive to specify that variable using custom taxonomies or meta fields?

3
  • Are you just displaying the value or are you filtering out the items in the loop? They are both about the same for a relatively small set of posts (less than 500). Oct 26, 2014 at 0:34
  • Filtering items in the loop. What about for many thousands of posts?
    – jetlej
    Oct 26, 2014 at 4:14
  • 2
    Are you developing the code for future use or on top of existing data? This is kind of question that is better answered with profiling in specific scenario than theory.
    – Rarst
    Oct 26, 2014 at 14:10

2 Answers 2

0

I had the same question here and it came down to this... It depends! (yep that's it). This is what Otto said...

Your question cannot be answered because you don’t give a proper scenario or framework by which to answer it.

Searching by meta value only is inefficient because it is not an indexed value. Searching by key and value is not as bad, because the key is indexed. Still bad, but not as bad for small sets. For it to be noticably bad, you would need to have multiple tens of thousands of posts and millions of meta. A large news site, for example.

If you’re talking about a rather small blog, then do what you like. Everything depends on scale.

No quantitative data exists because the answer is self-evident to anybody who understands databases and basic SQL queries. There is no need to measure that which is obvious.

If you're talking about many 1000s of posts then taxonomies might be better.

-1

On the Database the Taxonomies should be less intensive for sure, meta table gets crowded fast!

I mean, if you are dealing with an operation that doesn't change that much all the time it's ways better to try to cache stuff in anyway possible.

1
  • 5
    What is your basis for stating meta fills up faster than taxonomy in general? It might be your practical experience, but I would be hesitant to say this is reliable generic scenario.
    – Rarst
    Oct 26, 2014 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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