Skip to content

What is the fastest way to get all documents of a collection? #200

@rosenberg12

Description

@rosenberg12

I have a problem. I want to get all documents of a collection with ~ 1 mio documents inside. I asked myself what is the fastest way to get all documents inside a collection. Is it with cursor or with .all? And are there any recommendation for the batch_size? I would really appreciate a answer, thank you in advance.

cursor

from arango import ArangoClient

# Initialize the ArangoDB client.
client = ArangoClient()

# Connect to database as  user.
db = client.db(<db>, username=<username>, password=<password>)

cursor = db.aql.execute('FOR doc IN <Collection> RETURN doc', stream=True, ttl=3600, batch_size=<batchSize>)
collection =  [doc for doc in cursor]

.all - with custom HTTP Client

from arango import ArangoClient
from arango.http import HTTPClient

class MyCustomHTTPClient(HTTPClient):
    REQUEST_TIMEOUT = 1000

# Initialize the ArangoDB client.
client = ArangoClient(
    http_client=MyCustomHTTPClient())

# Connect to database as  user.
db = client.db(<db>, username=<username>, password=<password>)

students = db.collection('students')
collection = students.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions