Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do pagination in clickhouse

Tags:

clickhouse

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();
like image 324
Alaukik Srivastava Avatar asked Oct 30 '25 04:10

Alaukik Srivastava


1 Answers

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

like image 107
bambula Avatar answered Nov 03 '25 00:11

bambula



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!