[resolved] get_option - slow and uses waste of memory (3 posts)

  1. itzik770
    Posted 5 years ago #

    I'm very exited of WordPress at all, but it's slowness is discouraging.

    Lastly I'm found one of the bottlenecks of slowness and memory usage: the simply function get_option.

    First, I've found with WinCachegrind, that this function takes about 30% time, so I've stared to deep in the issue.

    So this function is working so (for now):

    By first call (actually - before it) - it loads all
    "autoloaded" option values from database to "object cache"

    So these values could be very long (tens of kilobytes) - all is loaded to object cache.

    Second: it's getting this vaste array of "alloptions" from object cache by each get_option call:
    $alloptions = wp_load_alloptions();

    where $alloption is almost whole content of "options" table.

    So I've started some optimization:
    1) I've added function to check if some key exists in object_cache - without need to return the cache value
    2) I've added function to return single option value from object cache and wrapped it in get_option function
    3) I've limited load_all_options with length of value 255 bit.

    So it working faster and using less memory.

    I can upload my code - but I'm neebee here.
    Should I upload my suggestion to 'track' also?

  2. Upload the suggestions to trac :)

  3. za_io
    Posted 4 years ago #

    would you mind sending me the code please? it would really help...

Topic Closed

This topic has been closed to new replies.

About this Topic