Opened 3 years ago

Closed 3 years ago

Last modified 2 years ago

#33646 closed New feature (fixed)

Adding async interface to QuerySet.

Reported by: Mariusz Felisiak Owned by: Andrew Godwin
Component: Database layer (models, ORM) Version: 4.0
Severity: Normal Keywords: async
Cc: Andrew Godwin, Carlton Gibson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Adding async interface to QuerySet for all data access operations that evaluate the queryset and are blocking calls.

See DEP-9.

Change History (13)

comment:1 by Mariusz Felisiak, 3 years ago

comment:2 by Carlton Gibson <carlton.gibson@…>, 3 years ago

In 6b53114:

Refs #33646 -- Added example for async cross-thread connection access.

comment:3 by Carlton Gibson <carlton.gibson@…>, 3 years ago

In 86324f37:

[4.0.x] Refs #33646 -- Added example for async cross-thread connection access.

Backport of 6b53114dd862ec97c282fdfdc83579cbd6d1560d from main

comment:4 by Mariusz Felisiak, 3 years ago

Needs tests: unset

comment:5 by Mariusz Felisiak, 3 years ago

Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:6 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

Resolution: fixed
Status: assignedclosed

In 58b27e0d:

Fixed #33646 -- Added async-compatible interface to QuerySet.

Thanks Simon Charette for reviews.

Co-authored-by: Carlton Gibson <carlton.gibson@…>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@…>

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 77926176:

Refs #33646 -- Added RawModelIterable.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 3 years ago

In 271a8e7:

Refs #33646 -- Made QuerySet.raw() async-compatible.

comment:9 by GitHub <noreply@…>, 3 years ago

In 1109e669:

Refs #33646 -- Reduced sync_to_async hops on async QuerySet iteration.

Until we add support for truly asynchronous database backends it's
actually detrimental to have complete set retrieval require multiple
hops between sync and async emulated contexts via asgiref.

By defaulting to sending the whole sync _fetch_all() to the current
context thread pool we reduce unncessary work when dealing with large
result sets since the queryset cannot be iterated anyway before all
results are retrieved and cached.

comment:10 by Carlton Gibson <carlton@…>, 3 years ago

In 4525d689:

Refs #33646 -- Fixed link markup in queries topic doc.

comment:11 by Carlton Gibson <carlton.gibson@…>, 3 years ago

In aa3197e5:

[4.1.x] Refs #33646 -- Fixed link markup in queries topic doc.

Backport of 4525d689e9ad4667e1798004c25053966c73c2d2 from main

comment:12 by GitHub <noreply@…>, 2 years ago

In e580b89:

Refs #33646 -- Moved tests of QuerySet async interface into async tests.

comment:13 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

In 8740d2f4:

[4.1.x] Refs #33646 -- Moved tests of QuerySet async interface into async tests.

Backport of e580b891cb5ae31eb0571c88428afb9bf69e47f2 from main

Note: See TracTickets for help on using tickets.
Back to Top