Add indexing to meta_value in wp_postmeta

Question

Is it poossible to add index to the meta_value column in the wp_postmeta table in order to make faster queries in WordPress?

I have about 5 million rows in the wp_postmeta table and my queries takes about 3 seconds when limited to 500 rows.

I am trying to do add an index to meta_value in phpMyAdmin but i am getting an error message saying:

column ‘meta_value’ used in key specification without a key length

I was thinking of converting it to varchar(255) but i have a meta value of _wp_attachment_metadata that is around 1500 characters long.

My query look like this:

Array
(
    [posts_per_page] => 500
    [orderby] => name
    [order] => ASC
    [post_type] => company
    [post_status] => publish
    [meta_query] => Array
        (
            [relation] => OR
            [0] => Array
                (
                    [key] => example1
                    [value] => 2
                    [type] => numeric
                    [compare] => =
                )

            [1] => Array
                (
                    [key] => example2
                    [value] => 2
                    [type] => numeric
                    [compare] => =
                )

            [2] => Array
                (
                    [key] => example3
                    [value] => 2
                    [type] => numeric
                    [compare] => =
                )

            [3] => Array
                (
                    [key] => example3
                    [value] => 2
                    [type] => numeric
                    [compare] => =
                )

        )

)
0
, , superhenke 4 years 2018-02-01T05:18:36-05:00 0 Answers 110 views 0

Leave an answer

Browse
Browse