Coder Social home page Coder Social logo

Incorrect indexes? about mongodb-queue HOT 8 CLOSED

chilts avatar chilts commented on August 19, 2024
Incorrect indexes?

from mongodb-queue.

Comments (8)

chilts avatar chilts commented on August 19, 2024

You might be right. I added these at the time when I thought I understood that they would be used correctly, but I don't think I was 100% certain. Since you seem to be using it quite heavily, would you be able to investigate which index/indexes need adding/changing?

I'd be happy to hear of what you think would help. I'm not currently using this module in such a heavy way, so I'm not experiencing the same issues (yet!). :)

Thanks for raising this.

from mongodb-queue.

longlostnick avatar longlostnick commented on August 19, 2024

I'll take a look and see what I can figure out. It may be just as easy as changing that index, but if that one IS used somewhere else it may require adding a new one. Either way I'll figure it out and pull request.

No problem! Great little package that's helped us get by with some basic queuing stuff without having to build out and maintain something bigger like RabbitMQ.

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

Cool, thanks. Yeah, I really quite like the idea (still) of using MongoDB as an store, especially due to the atomic operations it allows. You're right, perhaps those other indexes are used elsewhere, so might be worth a new index. I'll see if I get time tonight to refresh my memory on why I added those ones.

Perhaps it's because the query is looking for items where deleted doesn't exist, but the index only contains those rows where deleted does exist. By saying this, I'm presuming that the index won't include entries where deleted is non-existant.

Perhaps instead of:

{ deleted: 1, visible: 1, _id: 1 }

It should just be:

{ visible: 1 }

(Having _id in there also doesn't make sense to me now.)

What do you think?

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

Also, an index on { ack : 1 } might also be useful for both .ping() and .ack(). Again, what do you think?

from mongodb-queue.

longlostnick avatar longlostnick commented on August 19, 2024

Did you see my pull request? I think I got it figured out. #12

It's fine to have deleted first even if it's not in certain entries. Long story short, the main thing is that the order of the keys in the selector need to match the order of the keys in the index.

I went through audited all of the queries and consolidated them down into two indexes that make the most sense.

Keep in mind querying with ack will still use the compound index of { ack: 1, visible: 1, deleted: 1 }.

I'm gonna push it out to my production environment in the next week or so and followup with any findings.

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

You are awesome. :) Many thanks.

And I'm learning something new about indexes too! I've merged the PR and will re-release to npm shortly.

from mongodb-queue.

chilts avatar chilts commented on August 19, 2024

Released as v2.1.0. I've added you to the changelog in the README to say thanks. :)

from mongodb-queue.

longlostnick avatar longlostnick commented on August 19, 2024

Thanks! I'll report back if I run into any issues with my implementation.

from mongodb-queue.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.