DaveBirdsall commented on a change in pull request #1785: [TRAFODION-3265]
INSERT VARCHAR of UTF8 charset can be extremely slow
URL: https://github.com/apache/trafodion/pull/1785#discussion_r252430937
##########
File path: core/sql/optimizer/ItemExpr.cpp
##########
@@ -10984,20 +10984,16 @@ const NAString ConstValue::getText() const
{
if(getType()->getTypeQualifier() == NA_CHARACTER_TYPE)
{
- NAString result(CmpCommon::statementHeap());
- if (!textIsValidatedSQLLiteralInUTF8_)
- result += "\'";
- if (text_) result += *text_;
- if (!textIsValidatedSQLLiteralInUTF8_)
- result += "\'";
+ NAString result = getTextForQuery(QUERY_FORMAT);
// Change imbedded NULL and \377 chars to \0 and \377
// This comes up in key values quite often.
- size_t index;
- while((index = result.first('\0')) != NA_NPOS
+ size_t index = 0;
+ while((index = result.first('\0', index)) != NA_NPOS
Review comment:
Yes, I can see why the old code was slow. Order(n^2) in the length of result.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services