Skip to main content

orderBy InputObject

Each Cube generates an {Cube}OrderBy input object with ascending and descending fields. Each field accepts a CompareFields enum value that follows the dimension path joined by underscores:
For nested dimensions, each level is joined:
Usage:

Common CompareFields Values

Use the GraphQL IDE auto-complete to discover all available CompareFields values for a Cube — type orderBy: {descending: and the IDE will show available fields.

Usage

Pass an orderBy input object with either descending or ascending set to a CompareFields value:
orderBy accepts a single direction/field pair. Multi-column sorting is not supported — the query is sorted by one dimension at a time.

limit Argument

The limit argument controls how many rows are returned and supports offset-based pagination:

Default and Maximum Limits

Each Cube has a default limit applied when you omit the limit argument, and a maximum cap:
If you request a count exceeding the maximum, the server silently caps it at the maximum value.

Offset-Based Pagination

Use offset to page through result sets. The pattern is straightforward:
  • Page 1: limit: { count: 50, offset: 0 }
  • Page 2: limit: { count: 50, offset: 50 }
  • Page 3: limit: { count: 50, offset: 100 }

Example: Paginated Token Holders

Pagination Tips

Without a stable sort order, rows may shift between pages. Always pair limit with an orderBy that produces a deterministic order.
Large offset values (e.g., 50,000+) may degrade performance since the database must scan and skip rows. For very large datasets, narrow your query with where filters instead of paginating deeply.
If a page returns fewer rows than the requested count, you’ve reached the end of the dataset. Alternatively, use the count metric field to get total row count upfront.

Practical Examples

Latest Large Trades

Fetch the 10 most recent DEX trades on Solana with a buy value over $10,000:

OHLC Candles — Last 60 Minutes

Fetch 1-minute candles for a token, sorted chronologically:

Top 50 Token Holders

Fetch the top 50 holders sorted by USD balance:

Next Steps

Filtering

Combine ordering with filters to build precise analytical queries.

Metrics & Aggregation

Aggregate ordered data with count, sum, avg, min, max, uniq.