Hi,
This is urgent, can someone respond to this issue please?
Hi @sushantchawla2005,
WP Offload Media Support Team here. Thanks for reaching out with your query! We would be happy to assist.
At the moment, the plugin uses a query designed to account for different bucket configurations. It also includes a built-in caching system, so it doesn’t always need to call the database to retrieve a file’s offload URL. In addition, using an external object cache can further reduce database load, especially when paired with a page caching solution.
To help us check if the plugin’s built-in caching is working correctly on your site, can you please try editing your wp-config.php file and replace this line –
define( ‘WP_DEBUG’, false );
With these lines –
define(‘WP_DEBUG’, true);
define(‘WP_DEBUG_LOG’, true);
define(‘WP_DEBUG_DISPLAY’, false);
This means that any errors are logged to /wp-content/debug.log, because some errors are not visible on screen. More details about that at https://ww.wp.xz.cn/support/article/editing-wp-config-php/#wp_debug
Can you try the process again and then share the contents of the debug.log file in your next response? Feel free to redact any sensitive info.
Once we have finished troubleshooting, you should revert that config change and delete the debug.log file.
Hi @dbisupport
As it is a high traffic website and debug.log file is getting really heavy, can you provide me with any strings which you’re looking for in debug logs, please?
For the record, we are using the following Redis configuration:
define( 'WP_REDIS_CONFIG', [
'token' => "XXXX",
'host' => '/var/run/redis/redis.sock',
'port' => 0,
'scheme' => 'unix',
'database' => "XXXX",
'timeout' => 2.5,
'read_timeout' => 2.5,
'split_alloptions' => true,
'async_flush' => true,
'client' => 'phpredis',
'compression' => 'zstd',
'serializer' => 'igbinary',
'prefetch' => false,
'non_prefetchable_groups' => [ 'as3cf', 'yith_wcbm_badges' ],
'debug' => false,
'save_commands' => false,
'prefix' => DB_NAME,
] );
define( 'WP_REDIS_DISABLED', false );
Additionally, sometimes we don’t prefer to use Redis (object-cache-pro) due to conflicts and other reasons. Does that mean this plugin amazon-s3-and-cloudfront-pro will cause thousands of slow queries if we stop using Redis?
Looking forward to your quick response. Thanks!
Hi,
Please check the comparison of rows examined with and without wildcard
With wild card (1.8 Million rows examined):
MariaDB [XXXXXX]> EXPLAIN SELECT * FROM wp_as3cf_items WHERE (path LIKE '%uploads/2025/07/BVPK000273-2201478-1-300x300.webp' OR original_path LIKE '%uploads/2025/07/BVPK000273-2201478-1-300x300.webp');
+------+-------------+----------------+------+---------------+------+---------+------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------------+------+---------------+------+---------+------+---------+-------------+
| 1 | SIMPLE | wp_as3cf_items | ALL | NULL | NULL | NULL | NULL | 1829871 | Using where |
+------+-------------+----------------+------+---------------+------+---------+------+---------+-------------+
1 row in set (0.000 sec)
Same Query Without wildcard (Only 2 rows examined)
MariaDB [XXXXXX]> EXPLAIN SELECT * FROM wp_as3cf_items WHERE (path LIKE 'uploads/2025/07/BVPK000273-2201478-1-300x300.webp' OR original_path LIKE 'uploads/2025/07/BVPK000273-2201478-1-300x300.webp');
+------+-------------+----------------+-------------+------------------------------+------------------------------+---------+------+------+-------------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------------+-------------+------------------------------+------------------------------+---------+------+------+-------------------------------------------------------------+
| 1 | SIMPLE | wp_as3cf_items | index_merge | uidx_path,uidx_original_path | uidx_path,uidx_original_path | 762,762 | NULL | 2 | Using sort_union(uidx_path,uidx_original_path); Using where |
+------+-------------+----------------+-------------+------------------------------+------------------------------+---------+------+------+-------------------------------------------------------------+
1 row in set (0.000 sec)
This is a big difference.
Hi @sushantchawla2005,
Thanks for sharing your setup. We’re not Redis experts, but one thing that stands out is that as3cf is listed in your non_prefetchable_groups. WP Offload Media uses object caching if it detects that your server has one, and this setting could be preventing it from caching effectively.
Regarding the wildcard query, the plugin uses that type of lookup to account for different bucket configurations. But in normal circumstances, the plugin saves the storage version of the URLs in the amazonS3_cache postmeta record, and if an external object cache is available those cached values can be served even faster. This helps reduce calls to the database every time a page is loaded.
More about the amazonS3_cache record here: https://deliciousbrains.com/wp-offload-media/doc/developer-guide/#local-to-provider-data
At this stage, the next step is still to confirm whether the plugin’s own caching layer is working as expected. Plugin errors in the debug log should include the string as3cf or mention S3. If your debug.log is very large, you might try filtering it for those terms.
If you happen to disable Redis, WP Offload Media won’t automatically cause thousands of slow queries. That’s why it’s important we check the error logs first.
Hi @dbisupport
Thanks for your response. We are not using Redis on the application as it was causing some conflicts with plugins, so let’s assume we don’t have Redis available.
I believe the plugin uses amazonS3_cache as I have seen queries having this string regularly but the issue is those queries which doesn’t hit the cache. Our wp_as3cf_items table has 2127032 rows so whenever queries like the following one triggers, it causes a lot of resource usage and slowness.
MariaDB [XXXXXXXX]> SELECT * FROM wp_as3cf_items WHERE (path LIKE '%uploads/2025/07/BVPK000273-2201478-1-300x300.webp' OR original_path LIKE '%uploads/2025/07/BVPK000273-2201478-1-300x300.webp');
Empty set (33.923 sec)
MariaDB [XXXXXXXX]> select count(*) from wp_as3cf_items;
+----------+
| count(*) |
+----------+
| 2127032 |
+----------+
1 row in set (0.508 sec)
Due to the wild cards in these queries, it forces database engine to scan through 2 Million+ rows and use lots of resources.
If we use this query, it uses indexes and triggers really quick.
SELECT * FROM wp_as3cf_items WHERE (path LIKE 'uploads/2025/07/BVPK000273-2201478-1-300x300.webp' OR original_path LIKE 'uploads/2025/07/BVPK000273-2201478-1-300x300.webp');
Empty set (0.000 sec)
Additionally, I have tried to search for the strings as3cf or S3 in debug.log but there are no such entries there.
I hope this would help you apply the required optimisations to the plugin’s code. Looking forward to your response.
Regards,
Sushant Chawla