... します。 ビルトインの indexes を参照する Indexes は django.db.models.indexes で定義されていますが、簡単のため、 django.db.models 内にインポートされていま ... す。 from django.db import models を使用して、indexes を models.<IndexClass> として参照するのが標準的な慣習です。 Index オプション class Index ( * expressions , fields = () , n ... せんが、PostgreSQL はエラーを起こします。これは、 Concat() などの関数が受け入れられないことを意味します。 MariaDB Functional indexes are unsupported and ignored with MariaDB. fields Index. fields インデックスが必要なフィールド名のリストまたはタプル。 デフ ... ... ass TablespaceExample ( models . Model ): name = models . CharField ( max_length = 30 , db_index = True , db_tablespace = "indexes" ) data = models . CharField ( max_length = 255 , db_index = True ) shortcut = models . CharField ( max_length = 7 ) edges ... = models . ManyToManyField ( to = "self" , db_tablespace = "indexes" ) class Meta : db_tablespace = "tables" indexes = [ models . Index ( fields = [ "shortcut" ], db_tablespace = "other_inde ... ーブルと多対多テーブル) は tables テーブル空間に格納されます。name フィールドのインデックスと多対多テーブルのインデックスは indexes テーブル空間に格納されます。 data フィールドもインデックスを生成しますが、テーブル空間が指定されていないため、デフォルトで ... ... ugh tables cannot be generated currently. See the DEFAULT_AUTO_FIELD docs for details on migrating such tables. Functional indexes The new *expressions positional argument of Index() enables creating functional indexes on expressions and database functi ... = models . CharField ( max_length = 255 ) height = models . IntegerField () weight = models . IntegerField () class Meta : indexes = [ Index ( Lower ( "first_name" ), Upper ( "last_name" ) . desc (), name = "first_last_name_idx" , ), Index ( F ( "height ... " ) / ( F ( "weight" ) + Value ( 5 )), name = "calc_idx" , ), ] Functional indexes are added to models using the Meta.indexes option. pymemcache support 新たなキャッシュバックエンドである django.core.cache ... ... Xor() aggregate function returns an int of the bitwise XOR of all non-null input values. SpGistIndex now supports covering indexes on PostgreSQL 14+. ExclusionConstraint now supports covering exclusion constraints using SP-GiST indexes on PostgreSQL 14+ ... ation command allows optimizing operations for a migration. マイグレーション The new RenameIndex operation allows renaming indexes defined in the Meta.indexes or index_together options. The migrations autodetector now generates RenameIndex operations in ... stead of RemoveIndex and AddIndex , when renaming indexes defined in the Meta.indexes . The migrations autodetector now generates RenameIndex operations instead of AlterIndexTogeth ... ... reates a spatial index for the given geometry field. 注釈 This is different from the db_index field option because spatial indexes are created in a different manner than regular database indexes. Specifically, spatial indexes are typically created using ... a variant of the R-Tree, while regular database indexes typically use B-Trees. ジオメトリフィールドのオプション ジオメトリフィールドには追加オプションがあります。以下のすべてのオ ... ... the aggregated elements. The new BTreeIndex , HashIndex and SpGistIndex classes allow creating B-Tree , hash , and SP-GiST indexes in the database. BrinIndex now has the autosummarize parameter. The new search_type parameter of SearchQuery allows search ... lizers for migrations. モデル Added support for PostgreSQL operator classes ( Index.opclasses ). Added support for partial indexes ( Index.condition ). Added the NullIf and Reverse database functions, as well as many math database functions . Setting th ... . DatabaseFeatures.uses_savepoints now defaults to True . Third party database backends must implement support for partial indexes or set DatabaseFeatures.supports_partial_indexes to False . DatabaseIntrospection.table_name_converter() and column_name_c ... ... なりかねない可能性さえあることに十分注意してください。 標準的な DB 最適化のテクニックを使う 以下のようなものが上げられます: Indexes . This is a number one priority, after you have determined from profiling what indexes should be added. Use Meta.indexes o ... r Field.db_index to add these from Django. Consider adding indexes to fields that you frequently query using filter() , exclude() , order_by() , etc. as indexes may help to speed up lookups ... . Note that determining the best indexes is a complex database-dependent topic that will depend on your particular application. The overhead of maintaining an inde ... ... ケーションは Django 2.0 と互換可能となります。 Django 1.11 の新機能 クラスベースモデルのインデックス 新しい django.db.models.indexes モジュールはデータベースインデックスの作成を簡単にするクラスを含んでいます。インデックスは Meta.indexes オプションを使って ... Agg determines if concatenated values will be distinct. The new GinIndex and BrinIndex classes allow creating GIN and BRIN indexes in the database. django.contrib.postgres.fields.JSONField accepts a new encoder parameter to specify a custom class to enc ... DatabaseFeatures.supports_index_column_ordering attribute specifies if a database allows defining ordering for columns in indexes. The default value is True and the DatabaseIntrospection.get_constraints() method should include an 'orders' key in each o ... ... 05 ). Prevented AddIndex and RemoveIndex from mutating model state ( #28043 ). Prevented migrations from dropping database indexes from Meta.indexes when changing Field.db_index to False ( #28052 ). Fixed a regression in choice ordering in form fields w ... ... 2026年10月08日