mdmoss / doobie-codegen

Generate Doobie database code from sql statements.
MIT License
10 stars 7 forks source link

New MultiGets #65

Open DpEpsilon opened 5 years ago

DpEpsilon commented 5 years ago

Currently, the semantics of multiget (by primary key) provide that the output will be ordered the same as the input, and duplicate keys in the input will correspond to duplicate rows in the output. These semantics can be used for zipping the output with a list containing the input, although often it is unnecessary for this condition to hold.

The semantics of multigetBy are similar, although for each input there might be multiple rows of output, and the relative ordering of rows with the same key is undefined. I am not convinced these semantics are particularly useful, so I am inclined not to preserve them in a future version.

In either case, it may be helpful optimisation to provide a "fast" multiget which provides different or lesser guarantees. For example, output order could be undefined, or sorted by key (which would not pressure the database significantly more than leaving output order undefined). Additionally, a version of multigetBy could sort by foreign key then primary key so that there is a well-defined total ordering.