It will be advisable to add an index to a database field for better performance and quick selection of records from the database table.
Use the below snippet to add an index to database field in Magento 2.
->addIndex( $installer->getIdxName('table_name', ['table_field1', 'table_field2']), ['table_field1', 'table_field2'] )
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply