I am curious without doing a ton of benchmarks, how others feel about using several custom meta fields on a blog post? I am talking strictly performance wise, does it slow things down a lot if using a lot of fields, should we try to keep them to a minimum?
Currently for a regular blog post, I have a custom meta field for…
- Title: Used for page title
- Description: Used for meta description and social share description/text for Facebook and Twitter shares
- Keywords: Used for meta keywords
So I have 3 extra meta fields which are used so every article will have relevant SEO meta, also for when a user shares the article on Social networks, I can set the title and description easily.
I am wanting to add another field for Twitter #hashtags which I can then insert on Twitter shares, these will be similar to my articles tag taxonomy but may differ some so that is why I am thinking a custom meta field is the way to go.
I am also in the process of doing a custom post type for a portfolio which would also in addition to the above custom meta would add several more meta fields for this post type.
That is why I am curious about the performance impact of adding several meta fields?
Please share your thoughts
Custom Fields are normally fetched in a single query to the database, so fetching 1 or 10 isn’t going to make a lot of difference in performance of your WordPress site.
The problem is with doing complex meta queries on existing custom fields; that’s when your site would see a performance hit. Obvious, isn’t it?
Also, like @dotwired said, if your pages are cached properly, any possible performance hit can be contained.
As it has been pointed out there won’t be noticeable degradation of performance unless you had hundreds of thousands of custom fields and even then it would be a database scale issue not a WordPress issue. It looks like your question has already been answered, but am I the only one alarmed by the use of a custom meta field for a title when WordPress already provides a post_title field by default?
The one key rule you should follow is cache every single database read request that you can on your site. Take sites like Facebook for example, they execute over 60 million queries a minute, only 6 million or so of those requests ever hit the database due to caching. Your site won’t be dealing with the same amount of traffic, but it’s a good habit to get into.
If you’re adding in custom fields for SEO reasons, you’re probably better off using the plugin WordPress SEO by Yoast which allows you to have SEO titles, descriptions, keywords and more on your individual pages and posts.
And I know this goes outside of the scope of your question, but thought I’d also tell you about another plugin called Advanced Custom Fields which allows you to have smarter custom meta fields. I have no affiliation with the plugins mentioned whatsoever, I am a heavy user of them and thought it would help you out.
Regarding the pure performance point here: It doesn’t affect the page speed at all (not that much that it would notice anyone). This is a database thing, and it’s definitely not a problem to fetch WordPress one or two or even twenty rows more or less. Really.
In fact, if You want to speed up Your site, cache it. If You already do and it’s still very slow, think about a hosting improvement.