In the previous article, some people said that I did not say anything. Haha, if you have a high opinion, you are welcome to follow the post and do not say anything that is meaningless, you must know that not all people are as strong as you are! At the same time, this article will combine some small examples, especially small examples!
Data access problems
Scenario 1: Add new records
When we design to add a record, we sometimes use primary key auto-increment, sometimes generated in the program, usually return max (ID) + 1
Then, we need to get the ID first, and then insert the record. This is two times of database access! In other more complex scenarios, we have also increased the number of accesses between databases, which has a certain performance impact! Therefore, we can use stored procedures to replace similar or complex ones!
Scenario 2: You really don't want to use the entity set and return the query (talk nonsense). your second choice should not be dataset, but datareader! I think there are not many dataset features to use! Haha! Remember to use using () for convenience and peace of mind! Not everyone writes code, including me!
Scenario 3: Paging: To be honest, cainiao like me often read the code written by others and find many complete examples, similar to the "XXX" management system, in many cases, the data in it is directly dragged to the gridview to bind the data, and then set a paging attribute, It will be OK, but in fact it works like this, regardless of the large amount of data, the support for viewstate is also available on the basis of this page. As mentioned last time, it is indeed a very powerful thing and will be very powerful when used, because the Asp.net control mostly relies on it for its storage status! However, there are a lot of round-trips on the server, and the disadvantage is obvious! Therefore, we recommend that you use the stored procedure to implement your paging logic. The performance is good!
Cache
Scenario 1: page-level cache
:
<% @ Page outputcache varybyparams = "NONE" Duration = "300" %> it indicates that the page is cached for 5 minutes. If the page is accessed within 5 minutes, it is all accessed from the cache, similar to accessing static pages!
Scenario 2: Asp.net-level cache: For data with high access frequency and low change rate, we can cache the data and access it from the cache to reduce the number of database accesses, reduce database pressure! (I usually write the cache as configurable, and decide whether to cache the cache based on the configuration file. It is more flexible. This is an out-of-the-box question ).
Viewstate
There should be a place for him. Well, we don't have to be so cool, just on the web. config disables it. you can disable it on a page with a high level of access, because it does eat servers very much. Well, when writing data to the background, its advantages can be realized, we can take advantage of Asp.net, drag and drop, and then bind data, including data update and modification! After all, the background does not want the front-end to handle high traffic! We can also compress it by some means to reduce its size. The effect is very obvious! So you can use it as appropriate!
I have always believed that accumulated knowledge can be long, so I started from some so-called low-level knowledge points, but not everyone can master them well. So I hope everyone can share their skills they know, rather than simply saying "I did not say it, and the homepage lacks Management", I think you are not born to be a master, and new users cannot send their own ideas on the homepage, besides, I think about it myself. At least I have something to think about! Your speech may be inappropriate. If you have any mistakes, please forgive me!