databaseaerospike

Limit number of records in aerospike select query


I am trying to query using aql (Aerospike Query Language) in aerospike set.
Suppose there are 1000 records and I want to read any 10 records. Usually I would query something like :

select * from test.demo limit 10;

How do I query the same using aql ?


Solution

  • 2024 Edit on a really old (and obsolete) question Yes, AQL can use LIMIT. See https://aerospike.com/docs/tools/aql/querying_records#filter-on-indexed-bins

    The JDBC driver can do a limit too. See https://github.com/aerospike/aerospike-jdbc/blob/main/docs/examples.md

    Original answer from 2014:

    At the moment you cannot do that in aql, but you can use the BETWEEN predicate to define a range to the query.

    When you use the C-client (or one of the language clients that wrap around it) a scan (as_scan_foreach) can be limited by setting the percentage field of the as_scan struct.