Batch Processing

Overview

sqry batch executes a file of queries in a single invocation, sharing the loaded index across all queries. This avoids the per-query startup cost and is useful for CI pipelines, automated reports, and large-scale analysis.


Usage

Create a query file with one query per line:

# queries.txt
kind:function AND async:true
callers:authenticate
unused:true AND kind:function AND lang:rust
kind:class AND path:src/models/**

Run all queries:

sqry batch queries.txt .

Options

FlagDefaultDescription
--outputjsonOutput format: json, csv, tsv
--output-filestdoutWrite results to a file instead of stdout
--continue-on-errorfalseKeep running if a query fails
--statsfalsePrint execution statistics (time per query, total)
--sequentialfalseRun queries one at a time instead of in parallel

Parallel execution

By default, sqry batch runs queries in parallel, using the loaded index concurrently. This is safe because the index is read-only after loading.

Use --sequential when you need deterministic output ordering or when debugging a specific query:

sqry batch queries.txt . --sequential --stats

Structured output

Batch output wraps each query’s results in a top-level array, keyed by query:

sqry batch queries.txt . --output json
[
  {
    "query": "kind:function AND async:true",
    "results": [ ... ],
    "execution_ms": 12
  },
  {
    "query": "callers:authenticate",
    "results": [ ... ],
    "execution_ms": 8
  }
]

CSV and TSV output include a query column so results can be grouped after the fact.


Error handling

Without --continue-on-error, the batch stops at the first failed query and exits with a non-zero code. With it, failed queries are reported in the output but execution continues:

sqry batch queries.txt . --continue-on-error --stats

The --stats flag prints a summary at the end showing which queries succeeded, failed, and how long each took.


CI example

Run a standard set of quality checks in a single step:

- name: Run sqry quality checks
  run: |
    cat > /tmp/checks.txt << 'EOF'
    unused:true AND kind:function AND visibility:public
    kind:function AND name~=/TODO/
    EOF
    sqry batch /tmp/checks.txt . --output json --continue-on-error