MongoEngine / MongoEngine/mongoengine

Revamped index management

Open
#357 12 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

High Priority Performance
Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Hi @rozza!

Just wanted to pick your brain about the default index creation. Seems like non-background indexes are only useful at the very early stage of a project. When any of the collections grow fairly large (say above 1M documents), createIndex blocks the database for a significant amount of time.

It's a bit annoying to add {'index_background': True} in each Document's meta and sometimes you're just not able to control it that way. E.g. changing allow_inheritance will create a new non-background index (although I may be wrong whether _cls-related indexes respect meta's index_background or not).

I'd argue that { background: true } should be a default option in MongoEngine. What do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating MongoEngine’s index-creation path and the Document meta handling described here; compare how createIndex options apply to ordinary and _cls-related indexes. Establish the desired default behavior and its scope, then document or test the agreed behavior against MongoDB index creation.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.