4

Can you please suggest how can I do pagination in click house? Dor example in elastic search I do aggregation query like below. Here elastic search takes parameters partition number and partition size and give the result. Let's say in total we have 100 records than if we give partition size of 10 and partition number 2 then we will get 11-20 latest records.

How can we do it in click house considering data in inserting in a table.

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();
Pablosproject
  • 1,374
  • 3
  • 13
  • 33

2 Answers2

7

According to specification common sql syntax for limit and offset will work:

LIMIT n, m allows you to select the first m rows from the result after skipping the first n rows. The LIMIT m OFFSET n syntax is also supported.

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

bambula
  • 365
  • 1
  • 12
-2

I think you're wanting to only select a subset of the result set? I haven't needed to do this yet, but seems you could specify the format you want CH to return the data in (https://clickhouse-docs.readthedocs.io/en/latest/formats/index.html) and go from there. For instance, select one of the JSON formats as shown in the ^^ documentation and then get the subset of results appropriate for your situation out of the JSON response.