Title: as_has_wp_comment_logs loading
Last modified: August 11, 2024

---

# as_has_wp_comment_logs loading

 *  Resolved [peter8nss](https://wordpress.org/support/users/peter8nss/)
 * (@peter8nss)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/)
 * I’m tuning my page load performance. I’ve noticed that on every page there is
   an individual call to _get\_option _for _as\_has\_wp\_comment\_logs _– rather
   than this option being loaded as part of _wp\_load\_alloptions_.
 * The call originates from the _plugins\_loaded _hook as follows:
 *     ```wp-block-code
       get_option()wp-includes/option.php:197ActionScheduler_WPCommentCleaner::has_logs()wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/ActionScheduler_WPCommentCleaner.php:61ActionScheduler::init()wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php:209action_scheduler_initialize_3_dot_7_dot_4()wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/action-scheduler.php:60ActionScheduler_Versions::initialize_latest_version()wp-content/plugins/wp-mail-smtp/vendor/woocommerce/action-scheduler/classes/ActionScheduler_Versions.php:59
       ```
   
 * I think the problem is that, by default, there is no entry in the database options
   table for _as\_has\_wp\_comment\_logs _so it cannot be autoloaded. If there was
   an entry in the options table for _as\_has\_wp\_comment\_logs _with value _“no”_
   and _autoload=yes_, I think that would improve page load performance for most
   people using your plugin.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [crstauf](https://wordpress.org/support/users/crstauf/)
 * (@crstauf)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17948784)
 * I checked the query time for a specific option request from the database in one
   of my environments, and the query time was less than 0.0005 seconds. Trying to
   tune queries that fast is excessive and unnecessary. Is it an unnecessary call
   that could be optimized? Sure. But it won’t improve your site’s performance by
   any meaningful metric. If the query takes longer than 0.01 seconds, then there’s
   likely an infrastructure problem that needs to be addressed.
 * [@peter8nss](https://wordpress.org/support/users/peter8nss/) How much time does
   that query take in your environment?
    -  This reply was modified 1 year, 10 months ago by [crstauf](https://wordpress.org/support/users/crstauf/).
 *  Thread Starter [peter8nss](https://wordpress.org/support/users/peter8nss/)
 * (@peter8nss)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17949157)
 * You are correct that 0.0005s is not going to make much difference, but you won’t
   be surprised to know that your plugin is not the only one that has “unnecessary”
   get_option calls. And its starts adding up.
 *  [crstauf](https://wordpress.org/support/users/crstauf/)
 * (@crstauf)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17949237)
 * I can appreciate that, though 200+ queries (at 0.0005 seconds per) does sound
   suspicious. I’ll plan to submit a PR today, but it will be up to the maintainers
   to accept it, and they’re a small team with other priorities (so I’ve been told).
 * This filter may be helpful in the meantime, or with the other plugins: [https://developer.wordpress.org/reference/hooks/wp_default_autoload_value/](https://developer.wordpress.org/reference/hooks/wp_default_autoload_value/).
 *  Thread Starter [peter8nss](https://wordpress.org/support/users/peter8nss/)
 * (@peter8nss)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17949639)
 * Don’t think that filter is relevant as it is affects setting the autoload value
   when writing to the database. Whereas this topic is about entries that have never
   been written to the database.
 * Simpler workaround is just to add the option once through the CLI:
 *     ```wp-block-code
       wp option add as_has_wp_comment_logs no
       ```
   
 *  [crstauf](https://wordpress.org/support/users/crstauf/)
 * (@crstauf)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17950549)
 * For your reported situation it won’t, you are correct, but possibly for the other
   plugins that are running queries for single options.
 *  [crstauf](https://wordpress.org/support/users/crstauf/)
 * (@crstauf)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17950605)
 * Submitted PR:
   [https://github.com/woocommerce/action-scheduler/pull/1086](https://github.com/woocommerce/action-scheduler/pull/1086)
 *  [crstauf](https://wordpress.org/support/users/crstauf/)
 * (@crstauf)
 * [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17951212)
 * [@peter8nss](https://wordpress.org/support/users/peter8nss/) Coupled with your
   WP-CLI command, the following callback on [the `delete_option_option` action](https://developer.wordpress.org/reference/hooks/delete_option_option/)
   will ensure the option is always populated:
 *     ```wp-block-code
       add_action( 'delete_option_as_has_wp_comment_logs', static function ( $option ) {	update_option( 'as_has_wp_comment_logs', 'no' );} );
       ```
   
    -  This reply was modified 1 year, 10 months ago by [crstauf](https://wordpress.org/support/users/crstauf/).

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘as_has_wp_comment_logs loading’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/action-scheduler.svg)
 * [Action Scheduler](https://wordpress.org/plugins/action-scheduler/)
 * [Support Threads](https://wordpress.org/support/plugin/action-scheduler/)
 * [Active Topics](https://wordpress.org/support/plugin/action-scheduler/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/action-scheduler/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/action-scheduler/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [crstauf](https://wordpress.org/support/users/crstauf/)
 * Last activity: [1 year, 10 months ago](https://wordpress.org/support/topic/as_has_wp_comment_logs-loading/#post-17951212)
 * Status: resolved