Opened 12 years ago

Closed 12 years ago

#19630 closed Uncategorized (invalid)

documentation for QuerySet.exists() a bit misleading?

Reported by: knewB Owned by: nobody
Component: Documentation Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

https://docs.djangoproject.com/en/1.4/ref/models/querysets/#exists
says "calling QuerySet.exists() is faster than bool(some_query_set), but not by a large degree."

Using SQLite and MySQL, QuerySet.exists() results in

SELECT (1) AS "a" FROM foo WHERE bar LIMIT 1

rather than

SELECT EXISTS(...) 

but in any case, isn't this a lot faster than bool(some_query_set) ?

Change History (1)

comment:1 by Luke Plant, 12 years ago

Resolution: invalid
Status: newclosed

How much faster it is will depend on various factors (including how many rows there are in the DB that match the query, and also how the DB backend chunks results), and so it is not necessarily a lot faster.

As for the other thing you mentioned, you haven't shown a bug. If you can show that using EXISTS produces a significant performance gain, please detail your results and re-open.

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