Mongodb IXSCAN Problem

Hi,

I’m using MongoDB Compass. Version 1.43.5 and when I’m connect the localhost and create document and create a index. That index doesn’t work for IXSCAN. That mongodb always scanning with COLLSCAN.

Mongodb Compass says always theres no index. You can see all details on down below.

How can I solve that problem.




Hi @Developer_Providers,

I can answer for your issue as per my knowledge.

You have created the correct index but it seems you are hitting the wrong query to use your index. Try this: username: "" instead of {} . You need to provide the field name that you have specified in your particular index.

This documentation will help you understand your problem:

Let me know if it will resolve your problem or not.

Best,
Shreya

1 Like

Firstly, thanks for youre reply,

I wanted to shard collection and mongodb does not sharding collection to 3 shard. Its only holding 1 shard. I want to seperate each shard. I have 3 shard. As you can see down below.
but its holding one shard.

I mean, instead of keeping it in 1 shard, let it divide the data into all shards.

My Steps:

function randomString (len) {
    var charSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';

    var randomString = '';

    for (var i = 0; i < len; i++) {
        var randomPoz = Math.floor(Math.random() * charSet.length);

        randomString += charSet.substring(randomPoz,randomPoz+1);
    }

    return randomString;
}
1- use school;
2- sh.enableSharding("school")
3- sh.shardCollection("school.students", { email: 1 } )
4- data = [];
5- for (i = 0; i < 1000000; i++) data.push({email: randomString(40)}); }
6- db.students.insertMany(data, {ordered: false, writeConcern: {w: 0, j: true}});

I did that all steps and my sh.status log is:





image
image
image

Hi @Developer_Providers,

Can you provide details of the index you created for this collection?

Best,
Shreya

I just solved that.

mongodb m700 cluster says 64k IOPS per second but I need a 500k per second is that possible mongodb can handle it?