The Rewriter Query Rewrite Plugin pattern_database: NULL replacement: SELECT ? + 1 enabled: YES message: NULL pattern_digest: NULL normalized_pattern: NULL The rule specifies a pattern template indicating which  SELECT  statements to match, and a replacement template indicating how to rewrite matching statements. However, adding the rule to the rewrite_rules  table is not sufficient to cause the  Rewriter  plugin to use the rule. You must invoke flush_rewrite_rules()  to load the table contents into the plugin in-memory cache: mysql>  CALL query_rewrite.flush_rewrite_rules(); Tip If your rewrite rules seem not to be working properly, make sure that you have reloaded the rules table by calling  flush_rewrite_rules() . When the plugin reads each rule from the rules table, it computes a normalized (statement digest) form from the pattern and a digest hash value, and uses them to update the  normalized_pattern  and pattern_digest  columns: mysql> SELECT * FROM query_rewrite.rewrite_rules\G *************************** 1. row *************************** id: 1 pattern: SELECT ? pattern_database: NULL replacement: SELECT ? + 1 enabled: YES message: NULL pattern_digest: d1b44b0c19af710b5a679907e284acd2ddc285201794bc69a2389d77baedddae normalized_pattern: select ? For information about statement digesting, normalized statements, and digest hash values, see Section 27.10, “Performance Schema Statement Digests and Sampling” . If a rule cannot be loaded due to some error, calling  flush_rewrite_rules()  produces an error: mysql> CALL query_rewrite.flush_rewrite_rules(); ERROR 1644 (45000): Loading of some rule(s) failed. When this occurs, the plugin writes an error message to the  message  column of the rule row to communicate the problem. Check the  rewrite_rules  table for rows with non- NULL message  column values to see what problems exist. Patterns use the same syntax as prepared statements (see Section 13.5.1, “PREPARE Statement” ). Within pattern template,  ?  characters act as parameter markers that match data values. Parameter markers can be used only where data values should appear, not for SQL keywords, identifiers, and so forth. The  ? characters should not be enclosed within quotation marks. Like the pattern, the replacement can contain  ?  characters. For a statement that matches a pattern template, the plugin rewrites it, replacing  ?  parameter markers in the replacement using data values matched by the corresponding markers in the pattern. The result is a complete statement string. The plugin asks the server to parse it, and returns the result to the server as the representation of the rewritten statement. After adding and loading the rule, check whether rewriting occurs according to whether statements match the rule pattern: 1089