The site had 20K plus posts/pages/ect, freshly put live.
The hoster called. It had slow queries, 9 seconds on average. A lot, multiple per minute. The same query over and over again.
It was a pretty normal post table query. It had one part extra.
A meta query was to exclude all
spot_closed posts. When I removed that it was quick. It didn’t show anything special.
The meta query was added as such:
$meta_query_spots = [ 'relation' => 'OR', [ 'key' => 'spot_closed', 'value' => 1, 'compare' => '!=', ], [ 'key' => 'spot_closed', 'compare' => 'NOT EXISTS', ], ];
Check if the spot is closed, and if it a spot does not have a close status.
The fix, flip the checks. And bam query less then half a second.