Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-719

Collection name based lazy indexing

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None

      Description

      Lazily ensuring indexes based off dbName.collectionName (instead of class type) would be incredibly useful in cases such as collection based multi-tenant systems.

      Currently, the MongoPersistenEntityIndexCreator tracked index ensured collections classesSeen. This works very well when the entityClass:collection is 1:1. In cases such as the one mentioned above, a new tenant means a new collection and new indexes. In the current code, Spring Data will at best create a defaulted or "tenantless" collection to index which will likely never be used.

      If the index creator instead tracked by a resolved dbName.collectionName pattern, this would cover all mulit-tenant instances. However, it can no longer listen for an MappingContextEvent from the mapping context as this will no longer cover all cases where a new collection is required. It would most likely need to connect to an events on both a (yet to exist) BeforeFindEvent and BeforeSaveEvent and check to see if the target collection has been accessed yet. This cache of accessed collections can be exposed to a distributed caching, but ensuring indexes that already exist should be a minor operation for mongo.

      See the referenced URL. The project's workaround branch has a test showing desired functionality and workarounds to the current code to make it possible.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mp911de Mark Paluch
              Reporter:
              ccox Chris Cox
              Last updater:
              Mark Paluch
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 1d
                  1d
                  Remaining:
                  Remaining Estimate - 1d
                  1d
                  Logged:
                  Time Spent - Not Specified
                  Not Specified