[Glass] Query results as Streams and indexes question
Dale Henrichs via Glass
glass at lists.gemtalksystems.com
Thu Jan 5 19:07:11 PST 2017
On 1/5/17 5:38 AM, BrunoBB via Glass wrote:
> Hi All,
> For collection with indexes you can use a readStream for large query result
> (page 104 gs prg manual).
> If you try to send #readStream to a collection without an equality index
> a GsMalformedQueryExpressionError occurred (error 2710),
> reason:acceptPredicate:, Query may not be streamed.
I'd like to see the expression that generates this error ... it looks
like you are sending #readStream to a GsQuery and not a "collection". In
looking at the method
GsStreamableConjunctiveClauseChecker>>acceptPredicate: where this
particular error is signalled, there should be a more detailed
explanation of the reason for the error ... there are 4 different
possible reasons, so I need to see the complete error message to
understand what may have gone wrong..
> So in the case an application need aStream on a GsQuery --> you have to pay
> NO attention to "the rule of thumb" that only a collection with more that
> 2000 objects should have indexes (page 95 gs prg manual).
The rule of thumb is "As a rule of thumb, if your collection contains
fewer than about 2000 objects, it may not be worthwhile to create an
index", which has nothing to do with whether or not you should use a
stream to view results of a query.
> Is correct to say when a readStream is needed then you have to create the
> index after the first element is added ?
Whether or not you use a stream on the query results is really a
function of how bug you think the expected result will be ... for "small
result sets" it is not that expensive to use #queryResult.
#do: and #readStream both attempt to avoid scanning the entire result
set and can both be used if you don't intend to to scan the entire
result set... if you are going to touch all of the objects in the result
set, then using #queryResult is probably a bit more efficient than using
#do: or #readStream.
> Or my application code should be smart enough to use a readStream when there
> is an index present and a simple GsQuery without readStream when there is no
> index ?
I think you have misunderstood the reason for the error message above
... there are certain types of queries that are not streamable (look at
the error messages in
GsStreamableConjunctiveClauseChecker>>acceptPredicate:for the types of
queries that are not streamable).
And this error message has nothing to do with whether or not the
collection has an error present or not, but with the form of the query
that you are trying to execute... like I said earlier, if you show me an
example of the query itself, and/or provide the full error message I can
tell you a bit more about what may be going wrong ...
More information about the Glass