Skip to content

Commit 16669ba

Browse files
committed
improve performance of get_many
by making it use a different server REST API. It now uses the low-level document API instead of the `/_api/simple/lookup-by-keys` API. The former can be used as a drop-in replacement for the latter.
1 parent ff990fd commit 16669ba

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

arango/collection.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -993,19 +993,23 @@ def get_many(self, documents: Sequence[Union[str, Json]]) -> Result[List[Json]]:
993993
:raise arango.exceptions.DocumentGetError: If retrieval fails.
994994
"""
995995
handles = [self._extract_id(d) if isinstance(d, dict) else d for d in documents]
996+
997+
params: Params = {
998+
"onlyget": True
999+
}
9961000

9971001
request = Request(
9981002
method="put",
999-
endpoint="/_api/simple/lookup-by-keys",
1000-
data={"collection": self.name, "keys": handles},
1003+
endpoint=f"/_api/document/{self.name}",
1004+
params=params,
1005+
data=handles,
10011006
read=self.name,
10021007
)
10031008

10041009
def response_handler(resp: Response) -> List[Json]:
10051010
if not resp.is_success:
10061011
raise DocumentGetError(resp, request)
1007-
docs = resp.body["documents"]
1008-
return [doc for doc in docs if "_id" in doc]
1012+
return [doc for doc in resp.body if "_id" in doc]
10091013

10101014
return self._execute(request, response_handler)
10111015

0 commit comments

Comments
 (0)