[Resolved] get_option – slow and uses waste of memory
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?
- The topic ‘[Resolved] get_option – slow and uses waste of memory’ is closed to new replies.