bigbuger opened a new issue #7668:
URL: https://github.com/apache/shardingsphere/issues/7668


   Engine parsing the first SQL is particularly slow. This may be caused by a 
engine initialization take long time.
   My test code:
   ``` java
    private static SQLParserEngine getParseEngine() {
           return SQLParserEngineFactory
                   .getSQLParserEngine("MySQL");
       }
   
       private static void testParse(final List<String> sqlList) throws 
JsonProcessingException {
           final int testCount = 1000;
   
   
           final SQLParserEngine parseEngine = getParseEngine();
   
           final List<Map<String, Object>> result = 
Lists.newArrayListWithExpectedSize(sqlList.size());
   
           for (final String sql : sqlList) {
   
               System.out.println("test for sql:" + sql);
               final Map<String, Object> sqlTestResult = new HashMap<>(5);
               long min = Long.MAX_VALUE;
               long max = 0;
               long total = 0;
               long first = 0;
   
               for (int i = 0; i < testCount; i++) {
                   final StopWatch stopWatch = new StopWatch();
                   stopWatch.start();
                   final SQLStatement sqlStatement = parseEngine.parse(sql, 
false);
                   stopWatch.stop();
                   final long timeMillis = stopWatch.getTotalTimeMillis();
   
                   if (i == 0) {
                       first = timeMillis;
                   }
   
                   min = Math.min(timeMillis, min);
                   max = Math.max(timeMillis, max);
                   total += timeMillis;
               }
   
               sqlTestResult.put("sql", sql);
               sqlTestResult.put("first", first);
               sqlTestResult.put("min", min);
               sqlTestResult.put("max", max);
               sqlTestResult.put("average", total * 1.0 / testCount);
               sqlTestResult.put("testCount", testCount);
               result.add(sqlTestResult);
           }
           final ObjectMapper mapper = new ObjectMapper();
           System.out.println("test result:");
           
System.out.println(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(result));
   
       }
   ```
   
   Test result:
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to