Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

Firestore: coll_ref.list_documents() retrieves complete documents first, then returns doc_refs? #5

Description

@mikespub

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.

Metadata

Metadata

Assignees

Labels

api: firestoreIssues related to the googleapis/python-firestore API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions