Skip to Content
We are live but in Staging 🎉

STL_SORT

STL_SORT is a scalar index that improves query performance for filters on:

  • Numeric fields (e.g., INT8, INT16, INT32, INT64, FLOAT, DOUBLE)
  • String fields (VARCHAR)
  • Timestamp with timezone fields (TIMESTAMPTZ)

The idea is simple: Dodil (backed by Milvus) stores the indexed field’s values in a sorted array, so the engine can use binary search instead of scanning every entity.

When to use it

Use STL_SORT when your workload frequently uses scalar filtering, such as:

  • Comparisons: ==, !=, >, <, >=, <=
  • Ranges / sets: IN
  • Pattern matching on strings: LIKE

Typical examples:

  • E‑commerce: filter by price, in_stock, rating
  • Observability: filter by latency_ms, status_code, error_rate
  • Time-based apps: filter by created_at / event_time (TIMESTAMPTZ)

Supported data types

STL_SORT supports:

  • Numeric fields (INT*, FLOAT, DOUBLE)
  • VARCHAR
  • TIMESTAMPTZ

How it works

Milvus implements STL_SORT in two phases:

  1. Index build

    • During ingestion, the engine collects all values for the indexed field.
    • It sorts those values in ascending order.
    • Each value is stored alongside its entity ID.
  2. Query acceleration

    • At query time, the engine uses binary search to locate matching values:
      • For equality, it finds the block of identical values.
      • For ranges, it finds the start and end positions, then returns everything between.
    • The matching entity IDs are then used by the query executor to finalize results.

This typically reduces filtering work from a full scan O(n) to roughly O(log n + m), where m is the number of matched rows.

Create an STL_SORT index

STL_SORT does not require extra parameters.

Example: create an STL_SORT index on a TIMESTAMPTZ field named tsz.

from dodil import Client from dodil.vbase import VBaseConfig # Authenticate c = Client( service_account_id="...", service_account_secret="...", ) # Connect to your VBase database vbase = c.vbase.connect( VBaseConfig( host="vbase-db-<id>.infra.dodil.cloud", port=443, scheme="https", db_name="db_<id>", ) ) # Create STL_SORT index on the field `tsz` vbase.create_index( collection_name="tsz_demo", field_name="tsz", index_type="STL_SORT", index_name="tsz_index", # optional params={}, # no extra params needed )

What happens next

  • Index build may run asynchronously depending on your cluster size and data volume.
  • Some operations (like load_collection) may require the index to be ready.

Drop an index

Use drop_index when you want to remove the index from a collection (for example, to rebuild it with a different strategy).

vbase.drop_index( collection_name="tsz_demo", index_name="tsz_index", )

Usage notes

  • Best for scalar filters: STL_SORT is meant for filtering (predicates), not for vector similarity search.
  • No tuning knobs: there are no algorithm-specific parameters to tweak.
  • Memory-mapped mode: STL_SORT does not support mmap.

If you’re unsure which scalar index to pick, start with STL_SORT for heavy equality/range filtering, then iterate based on query latency and memory usage.

Last updated on