1

Here is what I am doing currently.

  1. Get data from database in DataTable (max records would be 100 but stored proc will search against more than 500,000 records. I already took care of search optimization in database. I am looking how I can improve the performance as much as I can in step# 2 and step# 3 below.)
  2. Create a generic list (List)
  3. Use that list and passing it to JavaScriptSerializer to get JSON back.

There are couple more options to generate JSON like DataContractJsonSerializer or JSON.NET or WCF. I wanted to know which options give better performance? Or any other way I can improve the performance?

2
  • Sorry, but it seems to me that searching of max 100 records from 500,000 records take much more time as the serialization of 100 records. So you should invest more in the optimazation of the stored procedure instead of JSON serialization. Commented Jul 13, 2010 at 19:06
  • I have taken care of that stored proc optimization. I also need to improve the performance on application side. So I wanted to make sure that I use the good approach that gives me the better performance because there are so many other ways to generate JSON. Commented Jul 13, 2010 at 21:57

1 Answer 1

3

Here are some perf results from the author of JSON.Net: http://james.newtonking.com/archive/2010/01/01/net-serialization-performance-comparison.aspx. The conclusion would be JSON.Net, if you care to use a third party library.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks Frank. One thing I don't understand where that deserialization comes in picture. I am just using JavaScriptSerializer class to serialize objects.
Well the perf results cover serialization and deserialization. If you only care about serialization it should be sufficient. That would imply some other component is doing deserialization, I couldn't tell you where that is without knowing more about the application you're working on.
I'd also agree with some of the other comments that this probably isn't your performance bottleneck... But JSON.Net is a good library to use either way.
Thanks. One more thing - As far as I know I can have ashx handler or web service or WCF that can be called from jQuery to get the data back in JSON format. Which one would you prefer ashx or WCF? Which one is light weight or can give better performance?
Well I've used both and prefer ashx. WCF is a pain to configure and gets in the way most of the time. Using their OperationContract/WebInvoke to set up a restful service, input parameters must all be strings or lists of strings, I still have to write code to do serialization. POST parameters are still shuttled as form parameters, even if they are JSON encoded objects. Kind of yuk. An ASHX page implementation should be lightweight enough- just check the request verb, content type header, then deserialize the request body.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.