Don’t limit the field, instead, limit the index, e.g.
ALTER TABLE wp_postmeta ADD key(meta_value(100))
This limits the index to the first hundred bytes of meta_value.
You’ll probably want an index on post_id, meta_key, meta_value for joins. How much of meta_key and meta_value is required depends on your data, for example
ALTER TABLE wp_postmeta ADD key(post_id, meta_key(100), meta_value(100));
Whether that helps with your query is another question. Get the SQL generated with $query->request
and then run it with “EXPLAIN $SQL” to see how MySQL handles it, which indexes are used etc pp.
Related Posts:
- What is an efficient way to query based on post_meta?
- database query with more than a couple meta hangs and doesn’t complete
- How to set up hierarchical relationships without using plugins / meta query
- 294 Queries on Mainpage of WordPress
- WP_Query by meta key not returning any posts
- WP Query Args – Title or Meta Value
- how to show posts that are missing a meta_value
- Does tax_query really beats meta_query in all situations?
- WP_Query using meta_query with relation OR and orderby meta_value doesn’t work
- querying with custom meta field with meta_query
- Order by two meta keys
- multiple meta key but get server load is very high
- A WP_Query that will look for posts after 2 weeks ago OR with a certain meta value
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- Query by meta_key and order by meta_value_num return orderby date
- WordPress altering my custom query, How to fix it?
- Order by meta_key in custom post type doesn’t affect the query
- How to create/modfiy WP_Query to search in post title OR custom field?
- Use meta_query to display events by date in custom field
- How to show recent and upcoming birthdays using meta_query
- Order Posts by meta value AND published date
- Using WP_Query and WP_Meta_Query Outside of WordPress
- What format does the meta_query TIME type require?
- How WordPress attaches its Featured Images with posts?
- If two first numbers exist in wp_meta_query value
- WP_Query on custom field and order results
- WP_Query filter and order by meta ordering by wrong joined table
- WP_Query last five posts, simply ordered by meta_value
- Tax query clause inside a meta query clause?
- What is the random string I am seeing when I use get_query_var?
- Optional Meta Query
- How do I make a meta_query OR relation work? [closed]
- Meta_query on same meta key, with diffrenct values
- Can we return all category (not post) with Custom Query Filter? [closed]
- Extend product search with meta in WooCommerce
- how to make members list directory through wordpress post custom meta key.
- Changing sort order for presentation by Jetpack infinite scroll
- get posts by meta_key from inside key of post meta
- Help optimizing slow WP_Query with meta_query
- meta_value_num not ordering all items
- Meta Queries – should nesting work after WP 4.1?
- Filter and Order by Multiple Custom Meta Values
- Meta Query relation “AND” then set array accordingly
- WP_Query with meta_query dosen’t return results
- Query with meta_query and tax_query together not working properly
- Is it possible to query from external database? [duplicate]
- Is it possible to query a custom field where the value is between two fields?
- Filter posts by comparing custom meta value against postdate
- How to provide meta_key array to wp_query?
- Specify strict ‘order by’ in WordPress query
- meta_query fails to compare on values containing apostrophes
- Does WordPress have something like Drupal’s DB API?
- Check if searched number is within the post meta value
- Meta query compare for ID’s greater than specific ID
- Is it possible to add relation between meta_query and tax_query?
- WP Query – filtering terms with regex
- add_query_arg to compare and display events from a certain date
- Show single posts date, in a page of posts
- Issue with data array format
- WP_Query Class custom field parameters
- meta_query where the meta value is not the post title
- Order WP_Query by meta_key priority when ‘OR’ relation used for multiple meta values
- Query on meta values and post title
- Custom Meta Query doesn’t work the same on two site
- meta_query with meta values as serialize arrays
- WP Query – grouping posts by same meta key, adding together values from another key
- Woocommerce Get Orders By Meta Value
- meta_query is overriding default search
- Multiple WP_Query args combinations according to post type
- WP_Query multiple value not working
- Query for current post
- wp query search multi terms
- WP_User_Query Orderby Not Working
- Translating WP query into to SQL query
- Unusual high query of user meta data
- WordPress Query optimaization for slow query
- WP_Term_Query->get_terms() very slow query for WordPress filter
- Meta query doesn’t remove placeholder escape before query
- WP Query Meta Query
- Query custom meta value – post view and date meta
- What is the best way to reset a search on a meta_key / meta_value?
- Slow query when selecting with large meta query or post__in
- How can I modify standard search query to include also ACF custom fields values?
- Custom WP_query and integrating into theme file
- WP_Query – show posts where meta value and user_email match
- WP Meta Query at depth 2
- Best way to Order Post in Home without a plugin
- WP_Query using meta_query with LIKE doesn’t return what it should
- Website goes slow down after importing long database
- Is there any difference between below WP_Query code snippets?
- Return a single custom post from multiple meta queries
- Sorting: custom query with orderby meta_value_num THEN by title
- query post based on comparison
- Including ‘cat’ => $cat breaks meta_query
- meta_query compare not doing what I want it to do
- Query string form $_GET[‘value’] is not working as meta value in wp_query
- WordPress extremely slow when using get_posts with multiple meta_query relations
- SQL query into to WP query
- Use meta query only 3 or more results?
- Use value from meta key array for use in WP_Query