Question about searches with multiple queries and using Advanced Custom Fields

WP Intense Q & ACategory: Scalability ProQuestion about searches with multiple queries and using Advanced Custom Fields
Mike Muller asked 4 years ago

I have a site that has about 3000 items in a custom post type. We’ve used Advanced Custom Fields to create some categories for each item in the CPT. The client wants to have a filter system to search for items in the CPT. There are 3 main sets of options. Each set has about 7 checkboxes in the search form. This creates quite a complex query because they want to use an "OR" condition inside each set of options and the and "AND" condition betwen the sets. So the customer gets option A, or option B from set 1 and option C or option D from set 2. Hope this makes sense.

When I tried to do this with WP Query, the query took a crazy amount of time to complete. I saw a number of articles on the web where it was mentioned that using lots of meta and taxonony options to WP Query slows it way down.

Will your plugin help with situations like this? Right now, I’m using a static JSON feed of all the products and just creating arrays of post ID’s to use. One I get all the ID’s that I need, I pass them into a WP Query to get the posts.

Let me know what you think and thanks in advance!

Anon replied 3 years ago

Yes it makes sense – your customer wants faceted search – it’s a normal requirement but something that unfortunately can prove difficult from a performance point of view. Rest assured I love solving these kind of performance problems, so if somehow Scalability Pro doesn’t already solve it I will add code to solve it for you.

1 Answers
Dave Hilditch Staff answered 3 years ago

Yes – it has built in sections to improve WP_Query – depends what you want to do with it –

For example, there is an option to switch off WP_Query pagination – to do this you need to use infinite scroll, but the boost it gives you is that the single table scan normally required to count the total items (and hence total pages) is no longer required and you get milliseconds response speed instead of whatever dreadful speed you are getting.

We use cookies

We use cookies for various things on our site, including our on-site chat bubble (if you use it), our comment forms (if you use them) and for session handling (if you log in).

Other than that, we use cookies to identify where traffic came from to help us understand which traffic turns into sales, we use a cookie for Google Analytics traffic analysis and we use a cookie to customise adverts for our own products we think you'll be interested in.

You can read more detail in our privacy policy page. Please click 'Accept' or 'Decline' to continue.