`PostgresStore` and `AsyncPostgresStore` always ran a batch inside a
pipeline. For a read that costs two round trips: fetching the result
forces one, and leaving the pipeline sends a Sync and waits for a
second. `store.get()`, `store.search()` and `store.list_namespaces()`
are batches of one read, so each paid two round trips, which is why a
`get` took longer than a `put`.
A batch of exactly one read now runs outside the pipeline, in one round
trip. Batches with several ops or any write still use the pipeline, and
so does a store opened with `pipeline=True`. In the sync store the
non-pipeline cursor now takes the store's lock, as every batch already
did through the pipeline branch, so a lone read never uses a shared
connection while another thread has it in a pipeline. That also covers
`sweep_ttl`, which went through that branch without the lock.
Median of four alternating rounds on main and on this branch, Python
3.14, Postgres 15 in local Docker:
| workload | main | this PR | speedup |
|---|---|---|---|
| round trips for 200 `get` calls, counted with a TCP proxy | 400 | 200
| 2x |
| 200 `PostgresStore.get` | 85.2 ms | 47.8 ms | 1.78x |
| 50 `PostgresStore.search` | 25.7 ms | 16.6 ms | 1.55x |
| 200 `AsyncPostgresStore.aget`, one after another | 103 ms | 59.5 ms |
1.73x |
| the same 200 `get` with 0.5 ms added per round trip | 433 ms | 228 ms
| 1.90x |
| graph node doing one `get` and one `put` per step, 50 steps | 46.8 ms
| 37.2 ms | 1.26x |
| `put`, and many concurrent `aget` batched together | | | about 1x |
## Test plan
- [x] The existing store suites pass for the sync and async stores in
their default, `pipeline=True` and pool setups, which cover the
lone-read path and the pipeline path.