my spark sql limit is very slow my spark sql limit is very slow elasticsearch elasticsearch

my spark sql limit is very slow


The source code of limit shows that it will take the first limit elements for every partition, and then it will scan all partitions.

To speed up the query you can specify one value of the partition key. Suppose that you are using day as the partition key, the following query will be much faster

select col from index where day = '2018-07-10' limit 10;