From a performance only perspective, can anyone with more more experience of the WordPress core tell me if writing something like a post view counter to a separate table in MySQL would be quicker for read and writes compared to using a Custom Meta Field?

I know most people will answer with Custom Meta Field solely on the reason that it's best to use the Wordpress API/functions. However my past 12 years has been building PHP applications that handle millions of users/high traffic and I know caching is the answer but I am interested in improving MySQL queries as well.

Looking at a lot of other plugins, I have seen it done both ways (for the record I am not asking this question for use in a plugin it will be for personal use in a theme)

Can anyone tell me any pros and cons of each method?

For example when a page is loaded in WordPress, I have not looked at how it is pulling in the meta fields, if it pulls them all in 1 query, it might be faster to use a meta field vs making another query to a separate table.

1 Answer 1


I can't really speak to the performance simply because I've not dug in to the internals. But from a pure logic approach the custom meta makes more sense to me.

The reason being that, at least from your description, you only really need a single field for each post/page. All you're doing is reading a value, incrementing it, and writing it.

Two lines of code using existing WordPress functions.

  • Hello, thanks for your comments. I agree on what you have said, I should say that my mention of writing a single column is just an example but I do think since it would be 1 column it would likely be better in a meta field, perhaps if I had a multi column table it would be more appropriate for a new table instead of the meta field. For example instead of just a view/hit counter it were to store the user ip, browser, and other analytic data
    – JasonDavis
    Commented Nov 14, 2012 at 21:30
  • 2
    Perhaps you ought to edit your question so you can get more meaningful and relevant answers, comments, and advice.
    – Steve
    Commented Nov 14, 2012 at 21:33

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.