Is it possible to clear the plan cache from a collection from c# or in the least... a .cmd?
The issue is that we have encountered intermittent problems where 2.6.4 is rendered inoperable (taking too much time) as a result of bad query plans.
Just about anything you can do in the shell you can do with any of the drivers, specially if the thing you want to do is command based.
I'm assuming you want to make use of this server command:
To clear all the cached query plans for a particular collection you can do something like this:
var command = new CommandDoc ument
{
{ "planCacheClear", "orders" }
};
database.RunCommand(command);
To only clear the cached query plan for a particular query you can do something like this:
var command = new CommandDocument { { "planCacheClear", " orders" }, { "query", Query.GT(" qty", 10).ToBsonDocument() }, { "sort", SortBy. Ascending("ord_date"). ToBsonDocument() } }; database.RunCommand( command);
Or, if you don't want to use the query builders:
var command = new CommandDocument { { "planCacheClear", " orders" }, { "query", new BsonDoc ument("qty", new BsonDocument( "$gt", 10)) }, { "sort", new BsonDocu ment("sort", new BsonDocument( "ord_date", 1)) } }; database.RunCommand( command);
You Rock!
댓글 없음:
댓글 쓰기