Advanced Custom Fields Scalability limits

Advanced Custom Fields is fantastic plugin used by millions that converts WordPress into a full stack CMS, allowing to create unlimited custom field groups, types and add them to any type of custom post type. However not many know about Advanced Custom Fields Scalability limits.

Quite often we get asked if GeoDirectory uses Advanced Custom Fields to manage listings custom fields. When we we reply that GeoDirectory has its own Custom Field System built in, they wonder why we decided to “reinvent the wheel”.

While the answer for us is crystal clear, Advanced Custom Fields Scalability is quite limited when it comes to building directories. We thought that maybe, being users, they are not aware of what is going on under the hood and about the scalability challenges that a web directory could present.

However, not too long ago, we stumbled upon a poll on a popular WordPress group on Facebook, where the option to vote for the “Best Directory” were : GeoDirectory, a few other Directory Themes available on popular marketplaces and there was also the option ACF + FacetWP.

When we saw the results, we were perplexed to say the least, ACF + FacetWP had a lot more votes than we would have thought.

People who voted were not supposed to be just simple users, but website developers and WordPress experts.

For this reason we decided it was time to explain why it is NOT a good idea to use Advanced Custom Fields for a directory and why Webbies shouldn’t offer that solution to anyone, unless they don’t care about providing fast, scalable solutions to their customers, that can grow in a sustainable way.

WordPress Custom Fields Scalability Limits

WordPress by default uses the wp_postmeta database table to store custom fields data and it creates 1 row for each custom field used in a post. Other than that WordPress adds a lot of extra data in this table for each post, each of which will use 1 row of the table.

If you spent some times optimizing SQL queries, you’ll know that’s not an ideal scenario for things like directories and filtering.

In fact the default database structure is potentially a huge bottle neck for websites with many posts and custom fields, it is considered one of WordPress’s weak points.

This is because to filter posts by custom fields, you’ll have to join the wp_post table with the wp_postmeta table in your query and the bigger the tables will grow, the slower the queries will become, worst of all if you want to filter by two meta values you would need to join the post_meta table twice to do it in the one query, this can eat up system memory and really slow things down for anything but a small directory.

Advanced Custom Fields Scalability Limits

Advanced custom fields is perfect for any website with a low or moderate number of posts, pages and custom fields in general.

However, except few rare cases, directories are just the opposite, they have a very high number of posts with potentially a very high number of custom fields too.

The main Advanced Custom Fields scalability issue is that it creates 2 rows in the wp_postmeta table of your database for each custom fields added to a listing, it will also add several postmeta rows belonging to its own settings.

This means that it will add more than twice the rows in the wp_postmeta table of your database compared to using the default WordPress custom field system.

We did a quick test that should help us better explain this matter.

We created a new WordPress website, we delete the hello world post, the sample page and we installed Advanced Custom Fields.

We created 1 group and 5 custom fields and we published 3 posts each using the 5 custom fields.

After this our wp_postmeta table already counted 83 rows. That’s insane, imagine the number of rows for a directory with 300,000 listings and 5 custom fields. With ACF your wp_postmeta table would count minimum 3,000,000 rows

How does GeoDirectory Scale?

That is very simple, we create a custom table for each of our custom post type.

Example: wp_gd_gd_place_detail

In this table we save all custom fields and their data, in a row for each post. We also built our own PHP API to query our custom tables just like WordPress has its own PHP API to query default wp database tables.

This means GD in most cases only has to join the post table to our own table, we can then filter those results by ANY custom field, we could filter by 20 custom fields where as ACF even with facetWP (which does speed things up but still has the core limitation) would have to join multiple tables over and over to do the same job in one query, using many times the server memory for the same query.

Conclusions

So if we compare GeoDirectory with WordPress or WP + Advanced Custom Fields, we see that:

WordPress
1) Requires an extra table JOIN for each custom field you want to filter by.
2) wp_postmeta quickly becomes big slowing down the queries

WP + ACF

1) Requires an extra table JOIN for each custom field you want to filter by.
2) wp_postmeta becomes twice as big compared to using WordPress alone

GeoDirectory

1) No join is required
2) GD does not add to the wp_postmeta info so does not create unnecessary bulk.
3) The database storing listings data counts 1 row per post

WordPress is known for this limitation in how it stores data, in most cases this system works fine but when it comes to large directories it’s just not the right solution that’s why with GeoDirectory you can create directory with millions of listings, while with WP + Advanced Custom Fields you are lucky if you can make a directory with few hundred listings without some serious hosting.

These are the Advanced Custom Fields scalability limits that made decide not to use it for GeoDirectory and this is why you shouldn’t use it too.

8 thoughts on “Advanced Custom Fields Scalability

  1. Thank you for the detailed post! Although I’ve used Geodirectory for few projects, I was looking to try out ACF + FacetWP for a new project just because I wanted to use native WordPress features.

    But this post explains nicely why that would be a pain long term, especially when the site starts getting popular with lot of people filtering/searching it!

    • You are welcome Farhan, the ACF + FacetWP solution looks awesome until you put it under stress with high traffic tests. We started dealing with WordPress scalability way before ACF or FacetWP were even released… 🙂

  2. One of the limitations that we have found with Geodirectory is that the Custom Post Types have a lot of default fields. 30+. That’s 30+ rows in the database for each post whether we use all of them or not.
    We seem to hit a max and started getting errors when we had 90+ database rows in a custom post type ( (1 for each custom field + default 30+ GD default fields)
    We were able to fix the problem somewhat by changing the default data type of some of the database rows / custom fields from varchar to text.

    There seems to be a lot of default fields in GD that we aren’t using and wish we could remove them to make space for custom fields we would actually use.

    Thanks for the post.

    • Hi John,

      GD does not add a row for each custom field, that is the point 🙂
      GD has this as a column, it is very rare for someone to reach the max columns length, this in theory should be over 4k but in reality it depends on the data types, but if they do it’s usually a case of not adding CF the best way and as you say if they are stored as text they don’t count to wards the max length of columns.

      Thanks,

      Stiofan

    • Hi Fiabio,

      I never tested that plugin, once I’ll find 5 minutes to install it on a staging site I’ll let you know, but testing it easy if you want to check on your own.

      Try to add a couple of custom fields to any post via it’s UI and after check where it is saving them in the DB. If it adds 1 row per meta like it’s uses WP standards.

      In that case it’s good for a limited n of posts and custom fields, especially if custom fields must be used as filters in advance searches.

      Thanks

  3. You are missing the point. ACF means I can apply a geolocation and attribute to ANY post/information. GeoDirectory only allows me to locate posts written by GeoDirectory. That’s why ACF and Facet gets supported

Leave a Reply to John Schuster Cancel reply

Your email address will not be published. Required fields are marked *

Share This