Looking at your code it looks perfectly fine. Although the more complex you make your query the more resources it is going to take and the longer it is going to take. You mention that your CPU usage rises to 80% which would be normal but how long is the usage holding at 80%? If its for a very short while then I wouldn’t worry about it.
What can you do to optimise the query… You could look at placing the data in a separate DB table where you can properly index the table to suit the queries you will be throwing at it. However doing this will require a fair bit of development work to get this done. If you want to go down this route then feel free to ask other questions on here to get your started.
Related Posts:
- Complex meta query with 3 keys
- How do I get create a custom table showing the hours remaining for all customers in one page from this transactions page?
- Grouping posts by a custom meta value
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- Custom user query – orderby meta_key (that may not exist)
- WP Meta Query – mixed AND / OR query doesn’t work
- Access Denied for User ‘root’@’localhost’ (using password: YES) – No Privileges?
- Cannot add or update a child row: a foreign key constraint fails
- How to make MySQL table primary key auto increment with some prefix
- sql query with multiple where statements
- Cannot delete or update a parent row: a foreign key constraint fails
- Syntax error due to using a reserved word as a table or column name in MySQL
- MySQL root password change
- Installation of MySQL for Visual Studio 1.2.8 failed
- How do I import an SQL file using the command line in MySQL?
- Authentication plugin ‘caching_sha2_password’ cannot be loaded
- Select from multiple tables without a join?
- SQL Query Where Field DOES NOT Contain $x
- Is there an SQLite equivalent to MySQL’s DESCRIBE [table]?
- Mysql command not found in OS X 10.7
- MySQL – UPDATE query based on SELECT Query
- grabbing first row in a mysql query only
- mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists
- Order a MySQL table by two columns
- MySQL AS keyword
- Should I use the datetime or timestamp data type in MySQL?
- Access denied; you need (at least one of) the SUPER privilege(s) for this operation
- How do I change the data type for a column in MySQL?
- Unknown Column In Where Clause
- Cannot connect to Database server (mysql workbench)
- mysqld: Can’t change dir to data. Server doesn’t start
- How to solve “Error: MySQL shutdown unexpectedly”?
- How to create a foreign key in phpmyadmin
- Can you do a For Each Row loop using MySQL?
- Drop all databases in MySQL
- How to properly create composite primary keys – MYSQL
- MySQL – count total number of rows in php
- How to get the count of each distinct value in a column?
- Data is not constantly loading from custom wordpress table
- How to run WordPress across 2 VMs for high availability
- Use REGEXP in WP_Query meta_query key
- Mysqldump add drop table?
- How to disable `SQL_CALC_FOUND_ROWS` [duplicate]
- “#1067 – Invalid default value for ‘post_date'” when trying to reset AI after backup
- meta_query key value from array
- #1115 – Unknown character set: ‘utf8mb4’
- WordPress Deadlock Error
- Order By Multiple Meta Fields
- How to do a MySQL dump from production site without using a search and replace script for local development?
- How to bulk edit canonical url’s in SQL?
- Concurrent / simultaneous MySQL connections
- How to check for empty and not a failure
- How many ‘wp_insert_post’ calls can be performed in one shot, in a very long ‘for’ loop?
- Keeping database within limits, please help!
- Best settings for MySQL to speed up site? [closed]
- HTML Entities in Post Title
- Can’t find my wordpress DB in phpmyadmin
- Deprecated: mysql_connect():
- $wpdb select all meta for each post
- meta_query issue with multiple numerics
- Calculate average crossing post categories
- Replacing link URL ending strings via MySQL
- Many slow queries post_type = ‘attachment’;
- How to get all users by custom current user meta (array)?
- SQL command to convert all tags in lowercase?
- Problem with admin login after deployment
- Find out how many times the user has logged in
- Is it possible to create a WordPress table using array and loop?
- Can’t run database query
- WordPress doesn’t display accents after migration
- How to stop $wpdb from prepending database name
- Match tag names with form titles
- Error missing MySQL extension
- Getting Error Trying to Create Table
- Best approach for a custom database filling in WP custom post types
- Why doesn’t custom mysql query return results? Is syntax correct?
- Multiple meta query from array
- Insert two row in wordpress database
- Convert a column of a table containing an Array as response in HTML
- Data is not constatntly loading from custom wordpress table
- Mysql Server keeps crashing
- How to improve my non-unique metadata MySQL entries?
- How to insert multiple rows and columns in database using array
- How to search usermeta table
- How to add virtual column in wpdb get_result statement
- PHP Warning: mysqli_error(): Couldn’t fetch mysqli in
- I want to share local developement and staging DB — Is this very smart or very stupid?
- Extract all users along with yoast metadata description
- WordPress asks to install, but is already installed?
- Deleting a table row through query
- An SQL query to find orphaned image attachments and their meta
- How can get all users by current user meta (array)?
- Weird characters displayed when importing WordPress MySQL db
- Simple SQL Query in wordpress
- Saving custom term value to the database in new table
- optimise SQL wordpress call
- Complicated MySQL Query
- WP_Query with LIKE returns strange query
- Initialization of table in database using ‘CREATE … IF NOT EXISTS’
- How can I show mysql locks?