Index: src/expr.c ================================================================== --- src/expr.c +++ src/expr.c @@ -3511,10 +3511,16 @@ assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); testcase( regFree1==0 ); testcase( regFree2==0 ); } break; + } + case TK_CONCAT: { + if( ConstFactorOk(pParse) && sqlite3ExprIsConstantNotJoin(pExpr) ){ + /* Try to run CONCAT operations at outside the inner loop */ + return sqlite3ExprCodeAtInit(pParse, pExpr, -1); + } } case TK_AND: case TK_OR: case TK_PLUS: case TK_STAR: @@ -3522,12 +3528,11 @@ case TK_REM: case TK_BITAND: case TK_BITOR: case TK_SLASH: case TK_LSHIFT: - case TK_RSHIFT: - case TK_CONCAT: { + case TK_RSHIFT: { assert( TK_AND==OP_And ); testcase( op==TK_AND ); assert( TK_OR==OP_Or ); testcase( op==TK_OR ); assert( TK_PLUS==OP_Add ); testcase( op==TK_PLUS ); assert( TK_MINUS==OP_Subtract ); testcase( op==TK_MINUS ); assert( TK_REM==OP_Remainder ); testcase( op==TK_REM );