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

Improve JDBC PreparedStatement performance

    Details

    • Type: Improvement
    • Status: In Progress
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 0.10.0
    • Fix Version/s: None
    • Component/s: JDBC Driver
    • Labels:
      None

      Description

      After my discussing with Hyunsik Choi 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

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

                Dates

                • Created:
                  Updated: