Skip to main content
The API automatically selects the most efficient index based on your query parameters. Understanding these patterns helps you write performant queries.

Index Usage

Queries filtered by tag use a dedicated tag index and are highly efficient. Use tag filters when possible for best performance.
{
  "filter": {
    "tags": { "any": ["hero", "product"] }
  }
}
Queries with name-based sorting use a dedicated index. Combining name sorting with status filters is optimal.
{
  "filter": {
    "status": { "eq": "active" }
  },
  "sort": [{ "field": "name", "order": "asc" }]
}
Queries with date-based sorting use the table’s primary index. This is the default and most efficient for recent assets.
{
  "sort": [{ "field": "createdAt", "order": "desc" }]
}
Queries combining multiple filters may use different execution strategies internally. The API automatically selects the most efficient index based on your query parameters.

Best Practices

Use Specific Filters First

More selective filters should be primary. Tag and type filters are highly optimized:
{
  "filter": {
    "tags": { "any": ["hero"] },
    "type": { "eq": "image/jpeg" },
    "size": { "lt": 5000000 }
  }
}

Limit Result Size

Always use pagination and reasonable limits:
{
  "filter": { ... },
  "limit": 50,
  "page": 1
}

Avoid Wildcards at Start

Pattern matching with leading wildcards (%name) is slower than trailing wildcards (name%):
// Faster
{ "name": { "like": "hero-%" } }

// Slower
{ "name": { "like": "%-hero" } }

Use Date Ranges

When filtering by date, provide both bounds when possible:
{
  "filter": {
    "createdAt": {
      "gte": "2024-01-01T00:00:00Z",
      "lte": "2024-03-31T23:59:59Z"
    }
  }
}