Title: Rewrite_rules sql query causing DB spike
Last modified: April 9, 2019

---

# Rewrite_rules sql query causing DB spike

 *  Resolved [sujrara](https://wordpress.org/support/users/sujrara/)
 * (@sujrara)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/rewrite_rules-sql-query-causing-db-spike/)
 * Hi Folks,
 * We are assuming this is a core wordpress issue.
    Repeated update on “options”
   table ‘WHERE ‘Option_name’ = ‘Rewrite_rules’ – This update is happening on each
   and every page load thereby increasing the load on DB CPU. Please let us know
   if this is the default WordPress behavior and how to get rid of this query or
   mitigate it.
 * Here is the query which is causing trouble:
    UPDATE `cms_options` SET `option_value`
   = ‘{{Data volume around 0.5MB}}’ WHERE `option_name` = ‘rewrite_rules’
 * Regards,
    Sujit

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

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/rewrite_rules-sql-query-causing-db-spike/#post-11413836)
 * Ideally it is not normal, but if code somewhere is calling something like flush_rewrite_rules(),
   then it would be expected. It’s advised to only call such a function upon theme
   or plugin activation for the very reason that it is computationally very expensive.
   But I’ve seen lots of code snippets that call such a function in a context where
   it is called on every page request.
 * If you can locate where such a function is called, it would be safe to comment
   it out on your site assuming it has already been called once for the current 
   configuration. It will be reinstated though when the offending plugin or theme
   is updated. If a published theme or plugin is doing this, it would be helpful
   to all if the responsible author were told they are Doing it Wrong™
 *  Thread Starter [sujrara](https://wordpress.org/support/users/sujrara/)
 * (@sujrara)
 * [7 years, 1 month ago](https://wordpress.org/support/topic/rewrite_rules-sql-query-causing-db-spike/#post-11415891)
 * [@bcworkz](https://wordpress.org/support/users/bcworkz/) Thank you so much. We
   were able to find “flush_rewrite_rules()” in the code and by removing this code,
   the issue is resolved and update not occurring now. Greatly appreciate your timely
   support.
 * Best Regards,
    Sujit

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

The topic ‘Rewrite_rules sql query causing DB spike’ is closed to new replies.

## Tags

 * [options table](https://wordpress.org/support/topic-tag/options-table/)
 * [rewrite_rules](https://wordpress.org/support/topic-tag/rewrite_rules/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [sujrara](https://wordpress.org/support/users/sujrara/)
 * Last activity: [7 years, 1 month ago](https://wordpress.org/support/topic/rewrite_rules-sql-query-causing-db-spike/#post-11415891)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
