0

I have an ASP.NET MVC3 C# 4.0 project.

This manages objects of type Person and actually I'm saving to a DataTable named person on a MySQL database.

The project has a search engine that finds persons from a keywords fulltext datatable. After I get the id corresponding to the person, I have a logic that does a GetPerson(id), but this creates a query to the person table and this query and creation of the object Person is slow.

What if I save beside the data in person table, I have another column in that table that has the full json string of a Person object? Then the GetPerson(id) gets only the json string and then doing a Serialize, I get the Person object?

Is this a good practice?

1
  • Can you post the code for GetPerson(id) and a code snippet of the context where it's running slow? That may just need to be optimized. Storing a serialized form of the object is redundant and forces you to double the number of sql update commands (must update JSON every time a field is changed). Commented Jul 27, 2011 at 18:34

1 Answer 1

2

This sounds a little confusing, you want to save the json into your database and perform full text searching on it? I'm not sure why you would want to do this. Why not have a table in your database that correlates to the fields found in the json fields, and update the table with new json requests. So if JSON contains (name, phonenumber, ...), you could then check whether name exists in the table ( if it does return the person id correlated to that name ) otherwise you can insert a new person into the table... Maybe I just read this wrong.

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

3 Comments

No, the fulltext search is in the keywords table. The json string, will be only for a GetPerson(id), i think it will be fast if only i get the json string with that id and seriallize it as a Person object.
But you know you're going to want to search/sort/whatever on Person stuff - sampwing is right.
this is far faster and more optimized approach

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.