2014년 12월 13일 토요일

Adding indexes to the namespaces collection

I have a very special group of developers who have an app the is dynamically creating collections , this is causing the name space file to get quite large and it is causeing namespace scans to take 100-1000ms. Can I ensure index on the "name" field in the namespaces collection ? This should remove the table scan and speed the app up quite a but i dont know if there is a issue with mucking with the system collections.



You can't and shouldn't put an index on the system.namespaces collection. It's not allowed - just try it in the shell and you will be rejected

> db.system.namespaces.ensureIndex({"name" : 1})
{
    "ok" : 0,
    "errmsg" : "cannot write to 'test.system.namespaces'",
    "code" : 2
}

The collection should only be read by clients (and even then, it's internal, so you shouldn't count on the format remaining the same over time). Where is your evidence of long system.namespace table scans coming from? I don't think you should see namespace lookups logged as normal queries. What driver/framework are you using? Some versions of ORM's do a lot of table scans of the system.namespaces collection, for some reason.



I see alot of this in my mongod logs

Wed Oct 29 12:31:29.435 [conn39922484] query discovery_data.system.namespaces query: { name: "discovery_data.blah_blahblah" } ntoreturn:0 ntoskip:0 nscanned:32212 keyUpdates:0 numYields: 251 locks(micros) r:5113487 nreturned:1 reslen:129 10380ms



As far as drivers and framework, its a nodejs app and that's about all I know,I'm not one of the devs, i'm just the guy trying to keep this pos from imploding on its self like a neutron star


댓글 없음:

댓글 쓰기