Uploaded image for project: 'Tajo (Retired)'
  1. Tajo (Retired)
  2. TAJO-1435

Improve JDBC PreparedStatement performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Major
    • Resolution: Unresolved
    • 0.10.0
    • None
    • JDBC Driver
    • None

    Description

      After my discussing with hyunsik on https://issues.apache.org/jira/browse/TAJO-1430, I create this issue.

      In this issue, Tajo PreparedStatement will be upgraded by using parsed SQL Context instead of using StringBuffer like the following.

      private String updateSql(final String sql, HashMap<Integer, String> parameters) {
      
          StringBuffer newSql = new StringBuffer(sql);
      
          int paramLoc = 1;
          while (getCharIndexFromSqlByParamLocation(sql, '?', paramLoc) > 0) {
            // check the user has set the needs parameters
            if (parameters.containsKey(paramLoc)) {
              int tt = getCharIndexFromSqlByParamLocation(newSql.toString(), '?', 1);
              newSql.deleteCharAt(tt);
              newSql.insert(tt, parameters.get(paramLoc));
            }
            paramLoc++;
          }
          return newSql.toString();
        }
      

      As a discussion, TajoCLI module has the same pattern, but TajoCLI exits immediately. So, we can not improve more at this side. If we want to improve both cases, we need to handle in deeper server side.

            if (cmd.hasOption("f")) {
              displayFormatter.setScriptMode();
              cmd.getOptionValues("");
              File sqlFile = new File(cmd.getOptionValue("f"));
              if (sqlFile.exists()) {
                String script = FileUtil.readTextFile(new File(cmd.getOptionValue("f")));
                script = replaceParam(script, cmd.getOptionValues("param"));
                int exitCode = executeScript(script);
                sout.flush();
                System.exit(exitCode);
              } else {
                System.err.println(ERROR_PREFIX + "No such a file \"" + cmd.getOptionValue("f") + "\"");
                System.exit(-1);
              }
            }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dongjoon Dongjoon Hyun
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: