# `TypeDB.Options`
[🔗](https://github.com/NoeticEcho/TypedbEx/blob/v0.11.0/typedb/lib/typedb/options.ex#L1)

Transaction and query options, and their translation to the HTTP wire format.

You do not normally call anything here. Pass these as ordinary keyword options
to `TypeDB.query/4`, `TypeDB.Transaction.open/4` or
`TypeDB.Transaction.query/3`, mixed in with everything else:

    TypeDB.query(conn, "social", query, transaction_type: :read, answer_count_limit: 100)

`TypeDB.Options.Query` and `TypeDB.Options.Transaction` are the canonical list
of which key belongs to which set — the driver splits your keyword list by
exactly that. `query_payload/2` and `transaction_payload/2` accept either form
and are here for tooling that builds requests itself.

## Transaction options

  * `:transaction_timeout_millis` — how long the server lets a transaction
    live at all, counted from the moment it opens. This is a server-side
    setting and is passed straight through; how long the driver itself waits
    for a response is `:timeout`, on the connection or on the individual call.

    **It is a lifetime, not an idle timer, and requests do not reset it.**
    Measured against 3.12.1: a transaction opened with
    `transaction_timeout_millis: 5_000` and given a query every two seconds
    answered at 2 s and at 4 s and was gone at 6 s. Left alone, the default is
    exactly **300 000 ms** — a transaction polled every ten seconds, so never
    idle for longer than that, died at 300 096 ms.

    What it costs you is `TSV12` — *"no open transaction"* — on the first
    request after the budget runs out, on a transaction that had been
    answering normally. Anything holding one transaction across a long unit of
    work has to raise this, `TypeDB.stream/4` above all.
  * `:schema_lock_acquire_timeout_millis` — how long a `schema` transaction
    waits for the exclusive schema lock.

## Query options

  * `:include_instance_types` — attach the type to every returned instance.
    **Turning it off is the largest saving available to a read**, and it is
    per query: only you know whether you already know the shape. Measured
    over an answer of 10,000 rows binding an entity and two attributes, on
    TypeDB 3.12.1:

    | | `true` (the default) | `false` |
    | --- | ---: | ---: |
    | bytes on the wire | 4,504,516 | 2,684,516 (−40%) |
    | decoding, end to end | 212 ms | 95 ms (2.2× faster) |
    | the decoded answer in memory | 8.16 MiB | 5.71 MiB (−30%) |

    The types are 40% of the bytes and half the decode. Leave it on while you
    are exploring, and turn it off on the read paths whose shape your code
    already knows.
  * `:answer_count_limit` — how many answers TypeDB materialises. **This
    raises TypeDB's own default of 10,000 as well as lowering it**: a read
    that matches more than that is truncated whether or not you set this, and
    the option is the only control — there is no server flag. Exceeding the
    limit produces a `warning` on the answer rather than an error, which the
    driver logs; see `TypeDB.Answer.warning/1`.
  * `:include_query_structure` — return the analysed pipeline structure
    alongside the rows, and populate `involved_blocks` on each row.

Options are accepted as plain keyword lists everywhere in the public API;
building these structs by hand is optional.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
