RESTier
RESTier copied to clipboard
[2.0] Delay Query Materialization
in DefaultQueryExecutor.ExecuteQueryAsync there's a call to query.ToList() that loads all results into memory
So, it appears that all QueryExecutors will execute their queries in-memory at some point during the process. This is a relatively standard pattern, even in WebAPI proper (return query.ToList() happens all the time).
So the question becomes, it is possible to delay materialization of the query until it is later in the pipeline. .NET Core has done so much work to optimize for performance, I'll have to see what we can do.
https://github.com/OData/RESTier/blob/45f858d8cb62f0c0d854b5cfdca61601f4cea409/src/Microsoft.Restier.AspNet/RestierController.cs#L587-L589
Hello, I think also this line materializes results unnecessarily:
https://github.dev/OData/RESTier/blob/38b8de60c0e7169f31e88872bc4e1313f754080a/src/Microsoft.Restier.EntityFramework.Shared/Query/EFQueryExecutor.cs#L69-L69
I tried changing from:
return new QueryResult(await query.ToArrayAsync(cancellationToken).ConfigureAwait(false));
to
return new QueryResult(query);
and there is no more loading of the whole query result in memory.