# Python client slower at retrieving query results than TypeDB Studio

**URL:** <https://forum.typedb.com/t/python-client-slower-at-retrieving-query-results-than-typedb-studio/152>\
**Category:** TypeDB\
**Tags:** typedb-client-python\
**Created:** [1 July 2022 15:43 UTC](https://forum.typedb.com/t/python-client-slower-at-retrieving-query-results-than-typedb-studio/152 "2022-07-01T15:43:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [1 July 2022 15:43 UTC](https://forum.typedb.com/t/python-client-slower-at-retrieving-query-results-than-typedb-studio/152/1 "2022-07-01T15:43:44Z")

</div>

When performing a simple query such as retrieving every Thing in the DB, the Python client is around five times slower than the other clients at fetching the answers.

Test case:

- Define a schema with a single attribute type, `first_name sub attribute, value string`
- Insert 50,000 first names, initialised to random UUIDs
- Run and collect all answers of `match $x isa first_name` in Client Python, and in TypeDB Studio

---

<div class="post-metadata">

**Author:** ![alex](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.typedb.com/alex/32/148_2.png) [@alex](https://forum.typedb.com/u/alex)\
**Post date:** [1 July 2022 15:45 UTC](https://forum.typedb.com/t/python-client-slower-at-retrieving-query-results-than-typedb-studio/152/2 "2022-07-01T15:45:37Z")

</div>

According to [Performance Best Practices | gRPC](https://grpc.io/docs/guides/performance/#python) :

> Streaming RPCs create extra threads for receiving and possibly sending the messages, which makes **streaming RPCs much slower than unary RPCs** in gRPC Python, unlike the other languages supported by gRPC.

This implies that the behaviour we see (where Python is significantly slower at retrieving query answers than Studio, which uses Client Java) is expected in gRPC Python.

The gRPC team propose one potential fix, which is refactoring Client Python to use `asyncio`. However, this is a significant undertaking, and with the development of `typedb-client-rust` due to be completed in the fairly near future, we will be rewriting Client Python as a thin Python wrapper over an underlying Rust library - which should run optimally, and resolve this issue.

In the meantime, if optimality is essential for a product, I’d recommend using Client Java, Node.js or Julia, via a separate microservice that connects to the Python program if needs be.

This issue is tracked in [Python client significantly slower when retrieving query results than Studio · Issue #257 · vaticle/typedb-driver-python · GitHub](https://github.com/vaticle/typedb-client-python/issues/257) .
