Skip to content

Go SDK docs: no index statements for exact-match, free-text, or JSON columns #1880

In review

Description

@auxesis

Background

The Go SDK is in languages/golang in this repository. Its user docs are the READMEs of encrypt and cmd/stashgen, the package doc comments, and the testable examples. pkg.go.dev shows all of them. In November 2026 we audited the docs of version v0.1.0-rc.7. AI agents built programs from the published docs alone, against a dev workspace and PostgreSQL 17 with EQL (Encrypt Query Language) v4. EQL is the SQL extension that stores and queries encrypted values.

Problem

The docs give index statements for ordered columns only. We tested an index for every column type on 1,000,000 rows. PostgreSQL chose each index with its default settings, and each query returned exactly the expected rows.

Column type Index statement In the docs With index Without
Exact match (TextEq) (eql_v4.eq_term(col)) no 0.014 ms 124 ms
Free text (TextMatch) USING gin (eql_v4.match_term(col)) no 46 ms 5,880 ms
Ordered, OPE (IntegerOrd) (eql_v4.ord_term(col)) yes 0.024 ms 173 ms
Ordered, ORE (IntegerOrdOre) USING btree (eql_v4.ord_term_ore(col)) yes 0.043 ms 3,115 ms
JSON containment (JsonSearch) USING gin (eql_v4.json_tree_query(col) jsonb_path_ops) no 43 ms 1,368 ms
JSON path ordering (eql_v4.ord_term(col -> '<selector>'::text)) no 1.5 ms 25,531 ms

Each time is the median of 5 or 7 runs, on PostgreSQL 17. The ordered rows time ORDER BY ... LIMIT 20.

The guide also needs these facts:

  • The ORE index took 82 seconds and 263 MB to build for 1,000,000 rows. The OPE index took 0.5 seconds and 7 MB.
  • The JSON path index needs a selector written into the statement as text. The selector comes from the generated Selector() method.
  • The 1,000,000-row table took 4,595 MB. An encrypted JSON document averaged 2,355 bytes.

Proposal

  1. Add an "Indexes" section with each statement, the query form it serves, and how to get a selector.
  2. Include the build cost and size figures, so users can plan.

Evidence

Verified on 1,000,000 rows with EXPLAIN ANALYZE.

Metadata

Metadata

Assignees

Labels

GolangSDKdocumentation

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions