Repository navigation
Description
Since 7.7.6 (#152) Blockstudio loads seven options with one query in Plugin::prime_option_caches(). On a page view without a persistent object cache that query still runs on every request. Measured with a query profiler on two sites running 7.7.13, it is the only query Blockstudio makes on the front page: 1 of 18 queries on a small site, 1 of 64 on a multilingual one.
SELECT option_name, option_value FROM wp_options WHERE option_name IN ('blockstudio_settings', ...)
< wp_prime_option_caches < Blockstudio\Plugin->prime_option_caches < Blockstudio\Plugin->init
Why it remains
wp_prime_option_caches() only skips options it finds in alloptions, in the object cache or in notoptions (option.php, the filter before the query). Without a persistent object cache the last two are empty when a request starts, so every listed option that is not autoloaded, whether it exists or not, keeps the query alive. As of 7.7.13 that applies to all seven:
| Option | Written | Read |
|---|---|---|
blockstudio_build_lock_cleanup_version |
autoload false, runtime-cache.php:153 |
runtime-cache.php:147 |
blockstudio_populate_cache_version |
autoload false, build-cache.php:441, :504 |
build-cache.php:386 |
blockstudio_collection_post_types_signature |
autoload false, pages.php:809 |
pages.php:805 |
blockstudio_pages_collection_manifests |
autoload false, pages.php:1207 |
pages.php:1218 |
blockstudio_pages_template_for |
autoload false, pages.php:1527 |
pages.php:1571 |
blockstudio_settings |
only by the migration, migrate.php:167 |
settings.php:463, :988 |
blockstudio_static_prerender_feature_state |
autoload true, deleted while prerendering is off (static-prerender-runtime.php:231, :2746) |
static-prerender-runtime.php:2722 |
The last two usually do not exist (no legacy settings to migrate, static prerendering off), and a missing option is never in alloptions.
Possible direction
- Write the five options Blockstudio maintains with autoload
nullinstead offalse. Since WordPress 6.6,nullisauto: the row is autoloaded unless the value is larger thanwp_max_autoloaded_option_size(150 KB by default), so a large collection manifest stays out ofalloptionsby itself. Existing rows switch once withwp_set_options_autoload()behind a small autoloaded version option. - Do not leave the two usually missing options to priming: either store their empty state once as an autoloaded row, or read them only when the feature is in use.
With both, wp_prime_option_caches() finds everything in alloptions and returns before the query. Sites with a persistent object cache see no difference. The cost is a few small rows (version strings, a signature, a short array) in the autoload query WordPress runs anyway.
Happy to send a pull request if this direction works for you, or to follow a different preference for the two missing options.
Activity
dnnsjsk commentedon Nov 10, 2026
Sounds good, lets do it like that @Contributolo, thanks!
Store the options read on every request autoloaded
Merge PR #207: optimize request options and prepare 7.7.14 [all]
dnnsjsk commentedon Nov 11, 2026
Released in Blockstudio 7.7.14, via #207 and 823a2fd. Small request options are autoloaded, missing fallback rows are initialized, and large collection configuration keeps WordPress’s size-aware policy. Migration updates existing values in place and also runs for theme-bundled Composer installs. Regression coverage verifies the query count, migration paths, and persistent-cache behavior. Full CI and distribution checks pass.