Support » Fixing WordPress » Dashboard page timing out with 6,000 posts

  • Resolved Michael Dance


    I’m in the process of filling a WordPress site with some 13,000 posts. All the posts will be of the custom post type “abstract”.

    I got 5,894 abstracts in the system when the /wp-admin/edit.php?post_type=abstract page (which lists all abstracts, 20 at a time) started timing out. I get a “memory size exhausted” error at /wp-includes/meta.php — the line number varies, but it’s always in the update_meta_cache function.

    My memory limit is already successfully set at 128M.

    I’m on a multisite install with the Domain Mapping plugin but no other plugins activated. All other backend and frontend pages are loading just fine. Any ideas?

Viewing 1 replies (of 1 total)
  • Update for anybody else having the same problem down the road: I finally tracked down a solution.

    For some reason, when the update_meta_cache function runs in /wp-admin/edit.php?post_type=abstract (or any post type) it seems to be trying to query the database for every meta key/value for every post of that post type with $wpdb->get_results. When you have a lot of posts with a lot of meta values, the query gets overloaded fast. (Not sure why it does this or if my understanding is correct — I went cross-eyed pouring through the core code.)

    Anyway, to fix it, luckily there’s a query var called “cache_results” you can set to false to prevent it from running update_meta_cache in the first place. Paste the following code in your theme’s functions.php file, replacing “abstract” with the name of your custom post type.

    function md_add_abstract_filter() {
        global $pagenow, $typenow;
        if ( $pagenow == 'edit.php' && $typenow == 'abstract' )
            add_action( 'parse_query', 'md_prevent_meta_caching' );
    add_action( 'admin_init', 'md_add_abstract_filter' );
    function md_prevent_meta_caching() {
          set_query_var( 'cache_results', false );

    Note that I’ve set it to only run where I was having the problem (/wp-admin/edit.php?post_type=abstract).

Viewing 1 replies (of 1 total)
  • The topic ‘Dashboard page timing out with 6,000 posts’ is closed to new replies.