use only one SQL query for all websocket multi-queries #9375
Labels
component/json-api
HTTP JSON API
team/ledger-clients
Related to the Ledger Clients team's components.
Milestone
Queries#selectContractsMultiTemplate
demands that the caller do some aggregation of thematchedQueries
data stored intemplateId
in some cases. This is represented by howtrackMatchIndices
setsPos=Int
inQueries
, butNonEmptyList[Int]
inContractDao
. Fundamentally, this is because where we use the generated predicate in SQL, we're in theWHERE
context and only producing blind booleans.We already put some effort into avoiding having to do this aggregation, so it only has to be done on multiqueries against the same template. Instead, we might shift this aggregation into the SQL generated query. There are a few ways we might do this:
WHERE
clause and use it in theSELECT
projection clause. In other words, each successful predicate yieldsTRUE
and also appends to amatchedQueries
variable, which is then added toSELECT
. I have no idea whether this makes sense.case when (tpidn = ? and predn) then [n] else [] end
where n is the index of(tpidn, predn)
, albeit only in the cases where the same tpid has multiple preds.union
the multiple SQL queries produced in theByInt
case and aggregate the indices. Probably significantly trickier than test java codegen with strange type / module names using daml-lf directly #2.Spun off of #9278.
The text was updated successfully, but these errors were encountered: