本文介紹 django.db.models.Index.include 的用法。
聲明
Index.include
Django 3.2 中的新函數。 
要作為非鍵列包含在覆蓋索引中的字段名稱的列表或元組。這允許 index-only 掃描用於僅選擇包含字段 ( ) 並僅按索引字段 (include  ) 過濾的查詢。fields 
例如:
Index(name='covering_index', fields=['headline'], include=['pub_date'])
將允許過濾 headline ,同時選擇 pub_date ,同時僅從索引中獲取數據。
使用include 將產生比使用多列索引更小的索引,但缺點是非鍵列不能用於排序或過濾。
include 對於 PostgreSQL 以外的數據庫將被忽略。
使用 include 時需要   。Index.name 
有關 covering indexes 的更多詳細信息,請參閱 PostgreSQL 文檔。
PostgreSQL 的限製
PostgreSQL 11+ 隻支持覆蓋 B-Tree 索引,PostgreSQL 12+ 也支持覆蓋   。GiST indexes 
相關用法
- Python Django Index.expressions用法及代碼示例
 - Python Int轉Bytes用法及代碼示例
 - Python Django InlineModelAdmin.get_extra用法及代碼示例
 - Python Django InlineModelAdmin.raw_id_fields用法及代碼示例
 - Python InteractiveConsole runcode()用法及代碼示例
 - Python InteractiveInterpreter runsource()用法及代碼示例
 - Python InteractiveInterpreter runcode()用法及代碼示例
 - Python IncrementalEncoder encode()用法及代碼示例
 - Python Django InlineModelAdmin.get_max_num用法及代碼示例
 - Python PIL Image.draft()用法及代碼示例
 - Python PIL Image.thumbnail()用法及代碼示例
 - Python PIL Image.new()用法及代碼示例
 - Python PIL ImageOps.fit()用法及代碼示例
 - Python Wand Image()用法及代碼示例
 - Python PIL ImageDraw.Draw.rectangle()用法及代碼示例
 - Python PIL ImageEnhance.Color() and ImageEnhance.Contrast()用法及代碼示例
 - Python Itertools.zip_longest()用法及代碼示例
 - Python PIL Image.getdata()用法及代碼示例
 - Python Itertools.compress()用法及代碼示例
 - Python PIL ImageFont.truetype()用法及代碼示例
 - Python Itertools.count()用法及代碼示例
 - Python PIL ImagePath.Path.tolist()用法及代碼示例
 - Python PIL Image.transform()用法及代碼示例
 - Python PIL Image.quantize()用法及代碼示例
 - Python PIL Image.point()用法及代碼示例
 
注:本文由純淨天空篩選整理自djangoproject.com大神的英文原創作品 django.db.models.Index.include。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
