The Rewriter Query Rewrite Plugin +------------------+-------+ For usage instructions, see Section 5.6.4.2, “Using the Rewriter Query Rewrite Plugin” . For reference information, see Section 5.6.4.3, “Rewriter Query Rewrite Plugin Reference” . 5.6.4.2 Using the Rewriter Query Rewrite Plugin To enable or disable the plugin, enable or disable the  rewriter_enabled  system variable. By default, the  Rewriter  plugin is enabled when you install it (see Section 5.6.4.1, “Installing or Uninstalling the Rewriter Query Rewrite Plugin” ). To set the initial plugin state explicitly, you can set the variable at server startup. For example, to enable the plugin in an option file, use these lines: It is also possible to enable or disable the plugin at runtime: Assuming that the  Rewriter  plugin is enabled, it examines and possibly modifies each rewritable statement received by the server. The plugin determines whether to rewrite statements based on its in-memory cache of rewriting rules, which are loaded from the  rewrite_rules  table in the query_rewrite  database. [mysqld] rewriter_enabled=ON SET GLOBAL rewriter_enabled = ON; SET GLOBAL rewriter_enabled = OFF; These statements are subject to rewriting: •As of MySQL 8.0.12:  SELECT ,  INSERT ,  REPLACE ,  UPDATE , and  DELETE . •Prior to MySQL 8.0.12:  SELECT  only. Standalone statements and prepared statements are subject to rewriting. Statements occurring within view definitions or stored programs are not subject to rewriting. •Adding Rewrite Rules •How Statement Matching Works •Rewriting Prepared Statements •Rewriter Plugin Operational Information •Rewriter Plugin Use of Character Sets Adding Rewrite Rules To add rules for the  Rewriter  plugin, add rows to the  rewrite_rules  table, then invoke the flush_rewrite_rules()  stored procedure to load the rules from the table into the plugin. The following example creates a simple rule to match statements that select a single literal value: The resulting table contents look like this: INSERT INTO query_rewrite.rewrite_rules (pattern, replacement) VALUES(’SELECT ?’, ’SELECT ? + 1’); mysql>  SELECT * FROM query_rewrite.rewrite_rules\G *************************** 1. row *************************** id: 1 pattern: SELECT ? 1088