The current implementation of CollectionReference.list_documents() seems to be seriously flawed.
Reading the API documentation at https://googleapis.dev/python/firestore/latest/collection.html it returns a sequence of doc_refs, which sounds like a good way to get (or count) all document references in a collection, without retrieving any unneeded data.
[Note: this is a bit like what a keys_only() query would do in Datastore mode, which doesn't really seem to have an equivalent select().stream() in native mode -> actually there is an equivalent, it's just not well documented: select([]) corresponds to select(["__name__"])]
So you would expect list_documents() to only retrieve doc_refs from Firestore in the back-end as well.
But what seems to happen in practice is that all document data are retrieved completely (with all fields) by the API, and then _item_to_document_ref() returns a doc_ref based on the document.
So this is actually the worst possible combination: you loose a lot of time/bandwidth retrieving all the document data and then simply discard it.
I'm not sure how this is implemented in other languages, but either list_documents() should continue returning only doc_refs but then only actually retrieve those doc_refs in the back-end. Or it if that's not technically possible for some reason, it should return actual docs, possibly with selectable field_paths like query().
Thanks,
Mike.
The current implementation of CollectionReference.list_documents() seems to be seriously flawed.
Reading the API documentation at https://googleapis.dev/python/firestore/latest/collection.html it returns a sequence of doc_refs, which sounds like a good way to get (or count) all document references in a collection, without retrieving any unneeded data.
[Note: this is a bit like what a keys_only() query would do in Datastore mode, which doesn't really seem to have an equivalent select().stream() in native mode -> actually there is an equivalent, it's just not well documented: select([]) corresponds to select(["__name__"])]
So you would expect list_documents() to only retrieve doc_refs from Firestore in the back-end as well.
But what seems to happen in practice is that all document data are retrieved completely (with all fields) by the API, and then _item_to_document_ref() returns a doc_ref based on the document.
So this is actually the worst possible combination: you loose a lot of time/bandwidth retrieving all the document data and then simply discard it.
I'm not sure how this is implemented in other languages, but either list_documents() should continue returning only doc_refs but then only actually retrieve those doc_refs in the back-end. Or it if that's not technically possible for some reason, it should return actual docs, possibly with selectable field_paths like query().
Thanks,
Mike.