Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i have 500k data in mongodb, and everytime i restart keystonejs, it will delete all indexes i set in mongo shell before! #102

Open
bookyo opened this issue Jan 17, 2021 · 2 comments

Comments

@bookyo
Copy link

bookyo commented Jan 17, 2021

i have 500k data in mongodb, and everytime i restart keystonejs, it will delete all indexes i set in mongo shell before!
Sometimes getting a piece of data can even lead to a 400% usage rate of mongodb and the process is stuck.
and i use mongodb profile log to optimize database index,and when i restart keystonejs, all my work will disappear.

its something wrong in relationship, keystone is not good at big data, even 10K data, At least in using mongodb.

@bookyo bookyo changed the title i have 50k data in mongodb, and everytime i restart keystonejs, it will delete all indexes i set in mongo shell before! i have 500k data in mongodb, and everytime i restart keystonejs, it will delete all indexes i set in mongo shell before! Jan 17, 2021
@kschingiz
Copy link
Contributor

@bookyo I had the same problem today, this line is causing the problem:
https://github.com/kschingiz/keystone/blob/master/packages/adapter-mongoose/lib/adapter-mongoose.js#L235
It just "refreshes" all collection indexes, to fix it try to define an index at schema level like this:

exports.Comment = {
  fields: {
    Author: {
      type: Relationship,
      ref: 'User',
      isIndexed: true
    },
  }
}

Add isIndexed = true field to your schema fields and keystone will create indexes by itself. For many-to-many relations which are defining new collection like project_users_user_projects you can create indexes as usually from mongo shell, keystone will not refresh them.
But I was not able to create compound indexes at all as they are dropped after sever restart :(

@timleslie timleslie transferred this issue from keystonejs/keystone Apr 19, 2021
@jmagder
Copy link

jmagder commented Nov 16, 2021

I just had this happen with a compound index I created manually. As far as I can tell there is no way to create compound indices is KeystoneJS, which if true should be a non-starter to using KeystoneJS in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants