Code

Ticket #5267: Fix5267.diff

File Fix5267.diff, 1.0 KB (added by mboersma, 7 years ago)

Added a warning sentence that order_by('?') may be expensive and slow

Line 
1Index: docs/db-api.txt
2===================================================================
3--- docs/db-api.txt     (revision 6292)
4+++ docs/db-api.txt     (working copy)
5@@ -211,11 +211,11 @@
6 --------------------------------------------
7 
8 Updating ``ForeignKey`` fields works exactly the same way as saving a normal
9-field; simply assign an object of the right type to the field in question::
10+field; simply assign an object of the right type to the field in question::
11 
12-    cheese_blog = Blog.objects.get(name="Cheddar Talk")
13-    entry.blog = cheese_blog
14-    entry.save()
15+    cheese_blog = Blog.objects.get(name="Cheddar Talk")
16+    entry.blog = cheese_blog
17+    entry.save()
18 
19 Updating a ``ManyToManyField`` works a little differently; use the ``add()``
20 method on the field to add a record to the relation::
21@@ -511,6 +511,9 @@
22 
23     Entry.objects.order_by('?')
24 
25+Note: ``order_by('?')`` queries may be expensive and slow, depending on the
26+database used.
27+
28 To order by a field in a different table, add the other table's name and a dot,
29 like so::
30