FQL\Results\Stream— a lazy generator that reads and processes rows on demand, without buffering the full result set.FQL\Results\InMemory— anArrayIteratorthat holds all result rows in memory at once.
ResultsProvider interface, so fetchAll(), fetch(), count(), and all other result methods work identically on either type.
Automatic selection
When you call$query->execute() without arguments, FiQueLa selects the result mode automatically:
JOIN and ORDER BY require loading data into memory. Joining builds an in-memory hash map of the right-hand table. Sorting must see every row before it can emit the first one. Queries that use neither operation can stream results row by row.Sorting with LIMIT
Since FiQueLa 3.2.2, ORDER BY combined with LIMIT keeps only the rows it can still return. FiQueLa reads the whole source once and feeds each row into a bounded Top-N heap. Peak memory stays at OFFSET + LIMIT rows instead of the full result set.
ORDER BY without LIMIT (or with OFFSET only) still buffers every row. It evaluates the sort keys once per row instead of on every comparison, which makes large sorts several times faster. Both paths return the same order as before, including ties, multiple keys, and mixed ASC / DESC.
Explicit selection
You can override the automatic choice by passing the desired class toexecute():
Comparing the two modes
Results\Stream
Results\Stream is a generator-based pipeline. Rows flow through each query phase (WHERE filter, SELECT projection, HAVING filter, LIMIT) one at a time. Memory usage stays low and roughly constant regardless of file size.
LIMIT early — it stops reading from the source file as soon as enough rows have been produced, which avoids scanning the entire file unnecessarily.
Results\InMemory
Results\InMemory stores all result rows in an ArrayIterator. Once populated it can be iterated any number of times without re-executing the query, and random access by offset is O(1).