In which cases do I need to call the index method in my migration file?
I don't really understand the description in the documentation.
In which cases do I need to call the index method in my migration file?
I don't really understand the description in the documentation.
Actually, in SQL
the indexing is a mechanism to speed up the database lookup. Hence, there are couple of types of indexing available including unique
and primary
. So, the index method is used to create an index of your table with provided keys where other indexes (unique and primary) have their own characteristics.
So, if you just want to create an index to speed up the query then use the index
method. this is a good reference to read about indexes.
An index is a distinct structure in the database that is built using the create index statement. It requires its own disk space and holds a copy of the indexed table data.
Basically, you don't need to create an index and if you use a column as primary key then that's enough, no need to create any index. Also you may check the wiki.