• hello,
    I have about 3 million rows in postmeta and 60 thousands rows in posts.

    when i checked for slow queries mysql, i notice that the core function meta_form() in wp-admin/include/template.php is taking about 6-7 seconds.

    Original query:
    SELECT meta_key
    FROM wp_postmeta
    GROUP BY meta_key
    HAVING meta_key NOT LIKE ‘\_%’
    ORDER BY meta_key
    LIMIT 30;

    I did some digging and I found a nice query to replace it:
    SELECT DISTINCT meta_key
    FROM wp_postmeta
    WHERE meta_key NOT BETWEEN ‘_’ AND ‘_z’
    HAVING meta_key NOT LIKE ‘\_%’;

    how can i do it in my theme or somewhere without changing the core?
    (no hook is available for that… as for i know…)
    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Even if you can replace the function by redefining it somewhere (not sure if that is possible) you will need to reapply your ‘patch’ after every update (that might change that function).

    So I don’t see why you shouldn’t modify that file. Just keep a history of all the changes you make to core files (if that’s important to you) and you’ll be able to reapply those patches after WordPress upgrades.

    Right?

    Moderator bcworkz

    (@bcworkz)

    No, you cannot redefine PHP functions. It is possible to directly edit the function declaration, but a bad idea.

    The only clean solution I see is to define your own metabox that calls your own function that contains the improved query string. Enable this metabox and disable the default custom fields box.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘replacing core un-pluggable function’ is closed to new replies.