[MDEV-6643] Improve performance of string processing in the parser Created: 2014-08-26 Updated: 2023-11-13 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
There is a bottleneck in how string literals are processed in the parser. 1. The function get_text() is sql_lex.cc allocates an unescaped copy of every string literal (unescaping backslashes and double quotes, if any). Strangely, copying happens even if there are no really any escapes in the string. 2. The syntax parser in sql_yacc.yy creates Item_string using the new unescaped buffer. I would be nice to create Items using directly the SQL fragment, without making a copy, including escaped values. Length in characters can also be calculated during the very first pass in get_text(), without any additional loops in the Item constructors. Unescaping can be done in the very end, when the value is actually needed:
The unescaped value should be cached, to make sure that val_str() does not do unescaping multiple times (e.g.per multiple rows), like in:
|
| Comments |
| Comment by Alexander Barkov [ 2014-10-28 ] |
|
Sent a new version for review, with the most important problems fixed:
Now it should be somewhat easier to review. |