clarkie / dynogels

DynamoDB data mapper for node.js. Originally forked from https://github.com/ryanfitz/vogels
Other
490 stars 110 forks source link

Question: select('COUNT') #92

Closed endymion00 closed 6 years ago

endymion00 commented 7 years ago

Hi @clarkie, Is it necessary to include .loadAll() when performing a count? In the documentation there is only this example: BlogPost .query('werner@example.com') .where('title').beginsWith('Expanding') .select('COUNT') .exec(callback);

I've performed a test and the query returns this object: { "Items": [], "Count": 2, "ScannedCount": 2 } It is not clear to me if the "Count" field will be always the real count (and maybe loadAll is needed). Please can you clarify this?

Thank you in advance!

clarkie commented 7 years ago

@endymion00 I'm not sure to be honest, I'd suggest you run some experiments with a large dataset and post the results back here when you're done. Thanks

cdhowie commented 6 years ago

@endymion00 I don't think loadAll() is needed. All that does is force the entire result set to be loaded when the response includes paging information -- it does not alter the request sent to the server, it just dispatches additional requests to fetch additional response pages if required.

A response for a COUNT query will never include paging information since there is only one result record. Ergo, loadAll() should not affect the behavior of a COUNT query.

endymion00 commented 6 years ago

ok, thanks guys