Optimize node label retrieval with aggregation
- Enable allowDiskUse for large datasets
This commit is contained in:
parent
778ad4f23a
commit
c51079335e
1 changed files with 6 additions and 1 deletions
|
|
@ -697,7 +697,12 @@ class MongoGraphStorage(BaseGraphStorage):
|
||||||
[id1, id2, ...] # Alphabetically sorted id list
|
[id1, id2, ...] # Alphabetically sorted id list
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cursor = self.collection.find({}, projection={"_id": 1}, sort=[("_id", 1)])
|
# Use aggregation with allowDiskUse for large datasets
|
||||||
|
pipeline = [
|
||||||
|
{"$project": {"_id": 1}},
|
||||||
|
{"$sort": {"_id": 1}}
|
||||||
|
]
|
||||||
|
cursor = await self.collection.aggregate(pipeline, allowDiskUse=True)
|
||||||
labels = []
|
labels = []
|
||||||
async for doc in cursor:
|
async for doc in cursor:
|
||||||
labels.append(doc["_id"])
|
labels.append(doc["_id"])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue