admin管理员组

文章数量:1397725

I’m currently developing an IoT application that uses GridDB to store and manage time-series data. My dataset is large and continuously growing, so I’m encountering performance issues when executing queries over extensive time ranges. I have taken the following steps to address the problem:

Data Schema & Indexing:

I’ve structured my container with a primary key and created an index on the timestamp column.

Data Distribution:

The dataset is distributed across multiple nodes to leverage GridDB’s scalability.

Despite these measures, queries that filter data by a specific time range still run slower than expected. Here’s a simplified version of my Java code for querying the data:

import com.toshiba.mwcloud.gs.*;
import com.toshiba.mwcloud.gsmon.*;

public class TimeSeriesQuery {

    public static void main(String[] args) {
    
        // Establish connection to the GridDB cluster
        GridStore store = GridStoreFactory.getInstance().getGridStore("clusterName", "username", "password");
    
        Container<?> container = store.getContainer("TimeSeriesContainer");
    
        // Define the query for a specific time range
        String queryString = "SELECT * FROM TimeSeriesContainer WHERE timestamp >= ? AND timestamp <= ?";
    
        Query query = container.query(queryString);
    
        // Bind parameters: startTime and endTime as long values (milliseconds since epoch)
        query.bind(new Object[]{ 1614556800000L, 1614643200000L });
    
        
        // Execute the query and process results
        RowSet<Row> rs = query.fetch();
    
        while (rs.hasNext()) {
    
            Row row = rs.next();
    
            // Process each row as needed
            System.out.println(row.toString());
    
        }
    
        // Close connection/resources as needed
        store.close();
    }
}

My Questions:

Are there any best practices or configuration options in GridDB specifically recommended for optimizing time-series queries?

本文标签: javaHow can I optimize timeseries queries in GridDB for improved performanceStack Overflow