Skip to content

Diffrence between find() cursor and aql.execute() returned cursor #76

@arturasjurev

Description

@arturasjurev

Python-arango==4.1.0
Arango=3.3.8

Create database with 1000 documents that has same data, but different keys (incremented 1-1000)

if not db.has_collection('data'):
    db.create_collection('data')
    data = db.collection('data')
    for i in range(0,1000):
        data.insert({'_key': str(i+1), 'data': True})

Extract same data via find() and db.aql.execute()

data = db.collection('data')
cursor = data.find({"data": True})
print('Data collection count : ' + str(data.count()))
print('find() | Cursor id : ' + str(cursor.id))
print('find() | Cursor count : ' + str(cursor.count()))

cursor2 = db.aql.execute(
    'FOR doc IN data FILTER doc.data == true RETURN doc',
    count=True,
    batch_size=100)
print('aql.execute() | Cursor id : '+ str(cursor2.id))
print('aql.execute() | Cursor count : ' + str(cursor2.count()))

Output is :

Data collection count : 1000
find() | Cursor id : None
find() | Cursor count : 100
aql.execute() | Cursor id : 19433873780390
aql.execute() | Cursor count : 1000

So in this case find() function returns only 100 documents, and since it has no ID - it's not possible to use fetch() rest 900documents and next() raises StopIteration exception.

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