fsprojects / FSharp.Linq.ComposableQuery

Compositional Query Framework for F# Queries, based on "A Practical Theory of Language-Integrated Query"
http://fsprojects.github.io/FSharp.Linq.ComposableQuery/
MIT License
67 stars 13 forks source link

Queries over nested structures #1

Closed ixtreon closed 10 years ago

ixtreon commented 10 years ago

Queries which use intermediate nested structures are not properly normalised and may generate multiple output queries.

To reproduce, run the benchmarking code and observe the execution time of tests ex8 and ex9 in Nested.fs: while we expect ex9 to take more time to execute under the F# 3.0 query builder (as compared to ex8), both queries should take roughly similar time under the TLinq builder which is not the case.

The problem seems to be in the handling of QueryBuilder.Run invocations, as the normalisation procedure does not explicitly recognise them.

We can either remove such calls or add a new literal in the internal representation representing calls to those, and rework the normalisation rules around it.

ixtreon commented 10 years ago

We can now recognise calls to RunQueryAsX, and replace them in the case of RunAsQueryable. This allows us to normalise across nested queries' boundaries and efficiently use nested structures in queries.

Note that calls to RunQueryAsEnumerable and RunQueryAsValue will still remain in the output. Removing these does not seem straightforward and is not essential to the performance of the library on database queries.

Since queries over nested structures work properly now, I am closing this issue.