There is possibility of two place where you can tune:
- IQuerable it self
- Controller.Json's Serialization method
For the IQuerable query, you could try sql profiler or try call ToList() before return it to see how long it take and possibly optimise it
(without more knowledge of your query, I can not help you).
But for the second part, you can try serialize the result using library like Json.Net
As from the source code, you can see that Mvc use JavaScriptSerializer
to do the json serialization, when you call the Json(). (you can also see what actually happen by looking at the source code)
From json.net website's comparison chart, the performace for JavaScriptSerializer
is quite bad.

So you could try implement your own JsonActionResult using Json.Net, some sample code below:
Source from : Using JSON.NET to return ActionResult
In your Controller (or base Controller)
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)
{
return new JsonNetResult
{
Data = data,
ContentType = contentType,
ContentEncoding = contentEncoding,
JsonRequestBehavior = behavior
};
}
And the definition for JsonNetResult:
public class JsonNetResult : JsonResult
{
public JsonNetResult()
{
Settings = new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
};
}
public JsonSerializerSettings Settings { get; private set; }
public override void ExecuteResult(ControllerContext context)
{
if (context == null)
throw new ArgumentNullException("context");
if (this.JsonRequestBehavior == JsonRequestBehavior.DenyGet && string.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
throw new InvalidOperationException("JSON GET is not allowed");
HttpResponseBase response = context.HttpContext.Response;
response.ContentType = string.IsNullOrEmpty(this.ContentType) ? "application/json" : this.ContentType;
if (this.ContentEncoding != null)
response.ContentEncoding = this.ContentEncoding;
if (this.Data == null)
return;
var scriptSerializer = JsonSerializer.Create(this.Settings);
using (var sw = new StringWriter())
{
scriptSerializer.Serialize(sw, this.Data);
response.Write(sw.ToString());
}
}
}