Open
Description
mongoid-slug: 5.3
I have a model Event
with the following slug specification:
slug :title, history: true, localize: true
Getting several unoptimized queries (2-6 secs) due to full on COLLSCAN's in my Mongo logs during slug generation. A few examples below:
I COMMAND [conn811652042] query db.events query: { $or: [ { _slugs.en: { $in: [ "lationship" ] } } ] } planSummary: COLLSCAN ntoreturn:1 ntoskip:0 nscanned:0 nscannedObjects:325827 keyUpdates:0 writeConflicts:0 numYields:2593 nreturned:0 reslen:20 locks:{ Global: { acquireCount: { r: 5188 } }, MMAPV1Journal: { acquireCount: { r: 2594 } }, Database: { acquireCount: { r: 2594 } }, Collection: { acquireCount: { R: 2594 } } } 1529ms
I COMMAND [conn810189219] query db.events query: { _slugs.en: { $all: [ /^new\-phone(?:-(\d+))?$/m ] }, _id: { $ne: ObjectId('<redacted>') } } planSummary: IXSCAN { _id: 1 } ntoreturn:0 ntoskip:0 nscanned:325596 nscannedObjects:325596 keyUpdates:0 writeConflicts:0 numYields:4610 nreturned:33 reslen:25751 locks:{ Global: { acquireCount: { r: 9222 } }, MMAPV1Journal: { acquireCount: { r: 4613 }, acquireWaitCount: { r: 1 }, timeAcquiringMicros: { r: 8420 } }, Database: { acquireCount: { r: 4611 } }, Collection: { acquireCount: { R: 4611 }, acquireWaitCount: { R: 2 }, timeAcquiringMicros: { R: 8592 } } } 6013ms
Mongoid slug creates an index on the _slug
field, not the slug.en
field. Indices should at least be created on the slug I18n.default_locale
field. Also, is there way way to override the default index created?