WP Engine Caps DB Query at 16KB

Hi All,

I had to write a quick one on this, as much for my benefit as anyone else’s. I actually found this out a few weeks ago now, but I forgot to blog on it, and then the client moved their site to production and the problem happened again and had me stumped again.

I had a WPDB query, I had used get_objects_in_term to group products with a bunch of attributes so I could then query against a bunch of ACF fields. I ended up with a query containing 4000-12000 post_id’s in IN(), and some other WHERE clauses. The query looked ok, no errors but was returning no results when it should almost certainly have been. I took out the WHERE clauses so it was basically just looking for posts IN those IDs, now it should definitely have results, but nothing. I took the query verbatim into PHPMyAdmin and low and behold results were found. I reduced the number of post_ids to only a few, and yes, results in WPDB query.

I went to WPEngine support and they were very helpful. While I was explaining the issue to them I wrote a little bit into my code so I could control the number of post_ids in the IN() clause, and it was finding results up to about 4000+ post_ids then nothing. Eventually the WPE support agent told me to try it again with full query and it worked.

He told me that WPE is capping query size at 16kb, to remove this cap you can add define(‘WPE_GOVERNOR’, false); to your wp-config.php.

Like the code you see here? You can hire me at Codeable.io - a WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard. See all developers you can hire through Codeable here.

Posted in Help Topics, News, Wordpress and tagged , , .

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.