Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

共进行三种查询:带值过滤的原始数据查询;带值过滤的聚合查询(Count和Max_Value两种),带值过滤的group by查询(Count和Max_Value两种+10-1000不同粒度)

实验结果

Image RemovedImage Added

如上表所示,可以发现,当选择率较低时,查询执行时间有明显的提升,选择率大于50%以后与原有时间持平。如上表所示,可以发现,在进行原始数据查询和聚合查询时,当选择率较低的场景下,查询执行时间有明显的提升,选择率大于50%以后与原有时间持平。

实验代码

Code Block
languagejava
import org.apache.iotdb.jdbc.IoTDBSQLException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCQuery {

    public static String[] sqls =
            new String[] {
                    "select s0 from root.sg1.d1 where s0<0",
                    "select s0 from root.sg1.d1 where s0<=1000000",
                    "select s0 from root.sg1.d1 where s0<=1000000&s1=1",
                    "select s0 from root.sg1.d1 where s0<=10000000",
                    "select s1 from root.sg1.d1 where s1=1",
                    "select s0 from root.sg1.d1 where s0<=50000000",
                    "select s1 from root.sg1.d1 where s1<=5",
                    "select s0 from root.sg1.d1 where s0>0",
                    "select count(s0) from root.sg1.d1 where s0<0",
                    "select count(s0) from root.sg1.d1 where s0<=1000000",
                    "select count(s0) from root.sg1.d1 where s0<=1000000&s1=1",
                    "select count(s0) from root.sg1.d1 where s0<=10000000",
                    "select count(s1) from root.sg1.d1 where s1=1",
                    "select count(s0) from root.sg1.d1 where s0<=50000000",
                    "select count(s1) from root.sg1.d1 where s1<=5",
                    "select count(s0) from root.sg1.d1 where s0>0",
                    "select max_value(s0) from root.sg1.d1 where s0<0",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000&s1=1",
                    "select max_value(s0) from root.sg1.d1 where s0<=10000000",
                    "select max_value(s1) from root.sg1.d1 where s1=1",
                    "select max_value(s0) from root.sg1.d1 where s0<=50000000",
                    "select max_value(s1) from root.sg1.d1 where s1<=5",
                    "select max_value(s0) from root.sg1.d1 where s0>0"
            };

    public static String[] sqls10 =
            new String[] {
                    "select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 10ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 10ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 10ms)",
                    "select count(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 10ms)",
                    "select count(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 10ms)",
                    "select count(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 10ms)",
                    "select count(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 10ms)",
                    "select count(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 10ms)",
                    "select max_value(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 10ms)",
                    "select max_value(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 10ms)",
                    "select max_value(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 10ms)"
            };

    public static String[] sqls100 =
            new String[] {
                    "select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 100ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 100ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 100ms)",
                    "select count(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 100ms)",
                    "select count(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 100ms)",
                    "select count(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 100ms)",
                    "select count(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 100ms)",
                    "select count(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 100ms)",
                    "select max_value(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 100ms)",
                    "select max_value(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 100ms)",
                    "select max_value(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 100ms)"
            };

    public static String[] sqls1000 =
            new String[] {
                    "select count(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 1000ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 1000ms)",
                    "select count(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 1000ms)",
                    "select count(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 1000ms)",
                    "select count(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 1000ms)",
                    "select count(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 1000ms)",
                    "select count(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 1000ms)",
                    "select count(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<0 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=1000000&s1=1 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=10000000 group by ([1, 10000000), 1000ms)",
                    "select max_value(s1) from root.sg1.d1 where s1=1 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0<=50000000 group by ([1, 10000000), 1000ms)",
                    "select max_value(s1) from root.sg1.d1 where s1<=5 group by ([1, 10000000), 1000ms)",
                    "select max_value(s0) from root.sg1.d1 where s0>0 group by ([1, 10000000), 1000ms)"
            };

    public static void main(String[] args) throws ClassNotFoundException, SQLException {


        Class.forName("org.apache.iotdb.jdbc.IoTDBDriver");
        try (Connection connection =
                     DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
             Statement statement = connection.createStatement()) {

            // set JDBC fetchSize
            statement.setFetchSize(10000);
            String sql = sqls[0];
            System.out.println(sql);
            long startTime=System.currentTimeMillis();
            ResultSet resultSet = statement.executeQuery(sql);
            outputResult(resultSet);
            long endTime=System.currentTimeMillis();
            System.out.println("time: "+(endTime-startTime)+"ms");
        } catch (IoTDBSQLException e) {
            System.out.println(e.getMessage());
        }
    }

    private static void outputResult(ResultSet resultSet) throws SQLException {
        if (resultSet != null) {
            System.out.println("--------------------------");
            System.out.println();
            while (resultSet.next()) {
            }
        }
        System.out.println("--------------------------\n");
    }
}

...