Support » Plugin: Redis Object Cache » DB query not being cached?

  • Resolved ExtremeLeadProgram.com

    (@extremeleadprogramcom)


    Running Woocommerce and have a fairly big wp_postmeta table and this query is slow when I access each order in the backend: `SELECT DISTINCT meta_key
    FROM wp_postmeta
    WHERE meta_key NOT BETWEEN ‘_’
    AND ‘_z’
    HAVING meta_key NOT LIKE ‘\\_%’
    ORDER BY meta_key
    LIMIT 30`

    I installed redis in hopes that it would cache that query to speed it up but it doesn’t seem to, see this screenshot, this is after reloading: https://nimb.ws/OKEyeV

    I’ve noticed a slight performance improvement and less DB queries via “query monitor” but this is one query that would help immensely. I am fairly new to object caching/redis so maybe I’m just missing something in config?

    Here is my diagnostics from the plugin: `Status: Connected
    Client: Predis (v1.1.4)
    Drop-in: Valid
    Disabled: No
    Filesystem: Working
    Ping: PONG
    Errors: []
    PhpRedis: Not loaded
    Predis: 1.1.4
    Credis: Not loaded
    PHP Version: 7.4.9
    Plugin Version: 2.0.13
    Redis Version: 3.2.12
    Multisite: No
    Global Prefix: “wp_”
    Blog Prefix: “wp_”
    WP_REDIS_PREFIX: “www.domain-redacted.com”
    WP_CACHE_KEY_SALT: “www.domain-redacted.com”
    Global Groups: [
    “blog-details”,
    “blog-id-cache”,
    “blog-lookup”,
    “global-posts”,
    “networks”,
    “rss”,
    “sites”,
    “site-details”,
    “site-lookup”,
    “site-options”,
    “site-transient”,
    “users”,
    “useremail”,
    “userlogins”,
    “usermeta”,
    “user_meta”,
    “userslugs”,
    “redis-cache”,
    “blog_meta”
    ]
    Ignored Groups: [
    “counts”,
    “plugins”,
    “themes”,
    “wordfence”,
    “wordfence-ls”
    ]
    Unflushable Groups: []
    Drop-ins: [
    “advanced-cache.php v by “,
    “Query Monitor Database Class v by “,
    “Redis Object Cache Drop-In v2.0.13 by Till Krüss”
    ]
    `

    Thank you in advance for any advice/help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Hi!

    Object Caching does not cache all SQL queries by default. If you want to cache additional components, you’ll have to do that manually.

    Thread Starter ExtremeLeadProgram.com

    (@extremeleadprogramcom)

    I figured that was the case. Without having to hire a developer could you point me in the right direction on how to do that?

    Plugin Author Till Krüss

    (@tillkruess)

    I’d optimize and ideally add an index for query.

    If you want to cache the query, you can read more about it here:
    https://codex.wordpress.org/Class_Reference/WP_Object_Cache

    Thread Starter ExtremeLeadProgram.com

    (@extremeleadprogramcom)

    The query is coming from Woocommerce core so I’m not sure what else I can optimize there. The DB appears to have indexes in place but it also has about 2 million records in it ( and that is after de-duping and optimizing it the best I can for now ).

    I looked through the WP Object Cache page. I understand just enough of it to roughly see how it works but not enough to know how to have it cache that query specifically ( or even if I should ).

    This question is not resolved.
    His question was if he can add wp_postmeta table to be cached.

    Plugin Author Till Krüss

    (@tillkruess)

    Tables cannot be cached.

    WordPress caches some query results.

    If you want to cache queries, you need to write your own logic for that using the wp_cache_*() functions.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.