Tian Jiang created IOTDB-122:
--------------------------------

             Summary: Support prepared insertion
                 Key: IOTDB-122
                 URL: https://issues.apache.org/jira/browse/IOTDB-122
             Project: Apache IoTDB
          Issue Type: New Feature
            Reporter: Tian Jiang


As some have mentioned, sql parser(antlr) may consume about 40% of time in 
ingestion, especially when small sqls executed sent frequently. Luckily, IoTDB 
insertion sqls are currently all alike and simple, there are 4 most meaningful 
parts of such sqls: deviceId, measurements, values and time. For such a simple 
structure, using tools like antlr may be just too heavy.

Intuitively, PreparedStatement in Standard JDBC interface can be just used for 
reliving parsing overhead when sqls are similar. I will describe how 
PreparedStatement works as follow (this is still left to be implemented):

1. The user wants to create a prepared insert statement and called 
`connection.prepareStatement(“Insert”)`;
2. The connection matches the parameter string with some templates, finds out 
it is an insertion and returns an IoTDBPreparedInsertStatement pStmt.
3. The user calls `pStmt.setDevice(“root.device1”); pStmt.setTime(100); 
pStmt.setMeasurements(measurementArray); pStmt.setValues(valueArray);` to set 
parameters for next insertion.
4. The user calls `pStmt.execute()` to execute an insertion.
5. The PreparedInsertStatement creates a TSInsertionReq, puts deviceId, 
measurements, values and time into this request and sends this request to the 
server.
6. The server receives the request, extracts parameters from the request and 
executes an insertion directly through database engine and return a 
TSInsertionResp to the user.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to