[patch] Operators for search_fields
|Reported by:||Andy Dustman <farcepest@…>||Owned by:||adrian|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Currently, search_fields in Admin always do an icontains search, i.e. ILIKE %...% search where ... is the search term. This is inefficient and undesirable in many cases because you cannot use an index and the database must search all rows.
The following patch (to be attached) extends this to add the following prefix operators and corresponding searches:
- ^: istartswith
- =: iexact
- @: search (full-text)
- no prefix: icontains (current behavior)
My tests indicate ^ makes my searches a lot faster. However, if there is at least one search field without a prefix, the database will still have to check every row.
Change History (7)
Changed 9 years ago by Andy Dustman <farcepest@…>
comment:1 Changed 9 years ago by Andy Dustman <farcepest@…>
- Summary changed from Operators for search_fields to [patch] Operators for search_fields