Purpose
This statement is used to create a fuzzy outline. You can create a fuzzy outline in two ways: one is by using FORMAT_SQL_TEXT (the original statement with parameters executed by the user), and the other is by using FORMAT_SQL_ID.
Limitations and considerations
To create an outline, you must be logged in as the corresponding user.
If
FORMAT_SQL_IDis the same, the outline created by usingFORMAT_SQL_TEXTwill overwrite the outline created by usingFORMAT_SQL_ID. The outline created by usingFORMAT_SQL_TEXThas a higher priority. In addition, OceanBase Database distinguishes different SQL statements by usingFORMAT_SQL_ID, which is obtained by taking theMD5hash ofFORMAT_SQL_TEXT. In a production system, we recommend that you bind an outline by usingFORMAT_SQL_ID.Note
- The matching rules of
FORMAT_SQL_TEXTignore the differences in parameter content, case, and non-syntactic symbols such as spaces and line breaks. It only compares the processed text content. FORMAT_SQL_IDis generated by formattingFORMAT_SQL_TEXT(removing extra spaces and line breaks and converting all characters to uppercase or lowercase), and then applying theMD5hash encryption to the formatted result.
- The matching rules of
Syntax
/* Create an outline by using FORMAT_SQL_TEXT */
CREATE [OR REPLACE] FORMAT OUTLINE outline_name ON format_stmt [ TO format_target_stmt ]
/* Create an outline by using FORMAT_SQL_ID */
CREATE [OR REPLACE] FORMAT OUTLINE outline_name ON format_sql_id USING HINT hint;
Parameters
| Parameter | Description |
|---|---|
| outline_name | The name of the fuzzy outline to be created. |
| OR REPLACE | If you specify OR REPLACE, the existing outline will be replaced if the specified outline already exists. |
| format_stmt | The original SQL statement.
NoteOceanBase Database automatically converts the unformatted SQL statement into a formatted SQL statement. |
| TO format_target_stmt | Optional. Specifies the target SQL statement to which format_stmt is converted or applied. This option allows the outline to be applicable to other SQL statements.
Notice
|
| format_sql_id | The format_stmt obtained after a series of rules are applied to the SQL statement to be bound. Then, the MD5 value of format_stmt is calculated to obtain format_sql_id. |
Examples
Create an outline by using
FORMAT_SQL_TEXT.CREATE FORMAT OUTLINE my_outline ON 'SELECT * FROM employees WHERE department_id = ?';Create an outline by using
FORMAT_SQL_ID.CREATE FORMAT OUTLINE my_sql_id_outline ON 'ED570339F2C856BA96008A29EDF04C74' USING HINT /*+ index(tbl1 idx_col2)*/;
References
For more information about using outlines, see Plan binding.
