Html.RenderAction performance?
I could like to have multiple Renderaction on my view, but one thing considering is that the perfomance of renderAction in this case.
For example, i have several modules and i could like to render it on the view, there are 2 ways to do it:
- Query in controller, which is long to call, we can do async here
- In the view, call RenderAction, the queries will be called by each renderaction
can you tell which one is better and which one is faster?
开发者_如何学运维Thank you
There is no general answer here. You have to make this decision case by case. Personally I lean towards making a single query as much as possible, since it reduces roundtrips to the database. But if your query involves cartesian products you're usually better off splitting into several queries (the RenderAction approach).
You also need to consider that the RenderAction approach yields more reusable actions. If reusability is necessary you might want to choose RenderAction even when it's not optimal performance-wise.
A mixed approach would be doing future queries. NHibernate supports multi queries, which can be used to transparently run several queries in a single roundtrip. This is called future queries, it's not yet released AFAIK, but you can apply this concept independently of NHibernate.
精彩评论