Introduction:
A provision to create indexes in MongoDB is made to enhance the performance of the Mongo DB.
Mongo Command- db.collection.createIndex()
The db.collection.createIndex() method is used to build an index on a collection.
The syntax for this command is as follows: db.collection.createIndex(keys, options)
Script Details:
db.categoryentity.createIndex({DisplayOrder: 1, ZnodeCategoryId: 1, ZnodeCatalogId: 1 , LocaleId: 1, VersionId: 1 , IsActive: 1})
Category Entity
- Indexes needed
- DisplayOrder
- ZnodeCategoryId
- ZnodeCatalogId
- LocaleId
- VersionId
- IsActive
- Order By
- DisplayOrder
Our Recommendation of queries to create the indexes:-
db.getCollection("categoryentity").createIndex( { "DisplayOrder": 1 } )
db.getCollection("categoryentity").createIndex( { "ZnodeCategoryId": 1 } )
db.getCollection("categoryentity").createIndex( { "ZnodeCatalogId": 1 } )
db.getCollection("categoryentity").createIndex( { "LocaleId": 1 } )
db.getCollection("categoryentity").createIndex( { "VersionId": 1 } )
db.getCollection("categoryentity").createIndex( { "IsActive": 1 } )
- db.logmessageentity.createIndex({CreatedDate: 1})
LogMessageEntity
- Indexes needed
- CreatedDate
- Order By
- CreatedDate
Our Recommendation of queries to create the indexes:-
db.getCollection("logmessageentity").createIndex( { "CreatedDate": 1 } )
db.versionentity.createIndex({ ZnodeCatalogId: 1, RevisionType: 1, LocaleId: 1})
VersionEntity
- Indexes needed
- ZnodeCatalogId
- RevisionType
- LocaleId
Our Recommendation of queries to create the indexes:-
db.getCollection("versionentity").createIndex( { "ZnodeCatalogId": 1 } )
db.getCollection("versionentity").createIndex( { "RevisionType": 1 } )
db.getCollection("versionentity").createIndex( { "LocaleId": 1 } )
db.configurableproductentity.createIndex({ZnodeProductId: 1, VersionId: 1})
ConfigurableProductEntity
- Indexes needed
- ZnodeProductId
- VersionId
Our Recommendation of queries to create the indexes:-
db.getCollection("configurableproductentity").createIndex( { "ZnodeProductId": 1 } )
db.getCollection("configurableproductentity").createIndex( { "VersionId": 1 } )
db.seoentitiy.createIndex({PortalId: 1, SEOTypeName: 1, LocaleId: 1 , VersionId: 1, SEOCode: 1})
SEOEntity
- Indexes needed
- PortalId
- SEOTypeName
- LocaleId
- VersionId
- SEOCode
Our Recommendation of queries to create the indexes:-
db.getCollection("seoentity").createIndex( { "PortalId": 1 } )
db.getCollection("seoentity").createIndex( { "SEOTypeName": 1 } )
db.getCollection("seoentity").createIndex( { "LocaleId": 1 } )
db.getCollection("seoentity").createIndex( { "VersionId": 1 } )
db.getCollection("seoentity").createIndex( { "SEOCode": 1 } )
db.addonentity.createIndex({DisplayOrder: 1, ZnodeProductId: 1, LocaleId: 1 , VersionId: 1, RequiredType: 1})
AddonEntity
- Indexes needed
- DisplayOrder
- ZnodeProductId
- LocaleId
- VersionId
- RequiredType
- Order By
- DisplayOrder
Our Recommendation of queries to create the indexes:-
db.getCollection("addonentity").createIndex( { "DisplayOrder": 1 } )
db.getCollection("addonentity").createIndex( { "ZnodeProductId": 1 } )
db.getCollection("addonentity").createIndex( { "LocaleId": 1 } )
db.getCollection("addonentity").createIndex( { "VersionId": 1 } )
db.getCollection("addonentity").createIndex( { "RequiredType": 1 } )
db.productentity.createIndex({ZnodeProductId: 1, SKULower: 1, ZnodeCatalogId: 1 , ZnodeCategoryIds: 1, LocaleId: 1, IsActive: 1 , VersionId: 1, ProductIndex: 1})
ProductEntity
- Indexes needed
- ZnodeProductId
- SKULower
- ZnodeCatalogId
- ZnodeCategoryIds
- LocaleId
- IsActive
- VersionId
- ProductIndex
Our Recommendation of queries to create the indexes:-
db.getCollection("productentity").createIndex( { "ZnodeProductId": 1 } )
db.getCollection("productentity").createIndex( { "SKULower": 1 } )
db.getCollection("productentity").createIndex( { "ZnodeCatalogId": 1 } )
db.getCollection("productentity").createIndex( { "ZnodeCategoryIds": 1 } )
db.getCollection("productentity").createIndex( { "LocaleId": 1 } )
db.getCollection("productentity").createIndex( { "ProductIndex": 1 } )
db.getCollection("productentity").createIndex( { "IsActive": 1 } )
db.getCollection("productentity").createIndex( { "VersionId": 1 } )
db.contentpageconfigentity.createIndex({PortalId: 1, IsActive: 1, ProfileId: 1 , VersionId: 1})
ContentPageConfigEntity
- Indexes needed
- PortalId
- IsActive
- ProfileId
- VersionId
Our Recommendation of queries to create the indexes:-
db.getCollection("contentpageconfigentity").createIndex( { "PortalId": 1 } )
db.getCollection("contentpageconfigentity").createIndex( { "IsActive": 1 } )
db.getCollection("contentpageconfigentity").createIndex( { "ProfileId": 1 } )
db.getCollection("contentpageconfigentity").createIndex( { "VersionId": 1 } )
db.textwidgetentity.createIndex({LocaleId: 1, PortalId: 1, VersionId: 1})
TextWidgetEntity
- Indexes needed
- LocaleId
- PortalId
- VersionId
Our Recommendation of queries to create the indexes:-
db.getCollection("textwidgetentity").createIndex( { "LocaleId": 1 } )
db.getCollection("textwidgetentity").createIndex( { "PortalId": 1 } )
db.getCollection("textwidgetentity").createIndex( { "VersionId": 1 } )
db.webstoreentity.createIndex({PortalId: 1, LocaleId: 1, PublishState: 1})
WebstoreEntity
- Indexes needed
- PortalId
- LocaleId
- PublishState
Our Recommendation of queries to create the indexes:-
db.getCollection("webstoreentity").createIndex( { "PortalId": 1 } )
db.getCollection("webstoreentity").createIndex( { "LocaleId": 1 } )
db.getCollection("webstoreentity").createIndex( { "PublishState": 1 } )
Steps to create a batch file:
- Set the database name in createindex.js file (use < database name>)
- Move createindex.js and createindex.bat file in “C:\Program Files\MongoDB\Server\3.2\bin”
- Run the createindex.bat file after publishing the store with the catalog to create the indexes in the database.