如何在clickhouse中进行分页

Ala*_*ava 4 clickhouse

您能建议我如何在 click house 中进行分页吗?在弹性搜索中的示例中,我执行如下聚合查询。这里弹性搜索采用参数分区号和分区大小并给出结果。假设我们总共有 100 条记录,如果我们给分区大小为 10、分区号为 2,那么我们将获得 11-20 条最新记录。

考虑到插入表中的数据,我们如何在 Click House 中做到这一点。

SearchResponse response = elasticClient.prepareSearch(index)
    .setTypes(documentType)
    .setQuery(boolQueryBuilder)
    .setSize(0)
    .addAggregation(AggregationBuilders.terms("unique_uids")
    .field(Constants.UID_NAME)
    .includeExclude(new IncludeExclude(partition,numPartitions))
    .size(Integer.MAX_VALUE))
    .get();
Run Code Online (Sandbox Code Playgroud)

小智 7

根据规范,限制和偏移的常见 SQL 语法将起作用:

LIMIT n, m允许您在跳过前 n 行后从结果中选择前 m 行。该LIMIT m OFFSET n语法也受支持。

https://clickhouse.yandex/docs/en/query_language/select/#limit-clause