Chat with naked wemon for free - Updating multiple rows in sql server 2016
If there are other requests sent in this time window, the data will surely be contaminated, so we should block the other requests, and never execute the update statement before finishing the select statement. Adding a transaction may be the solution, and the transaction isolation level must be Read committed or higher.
The front-end and back-end engineers start discussions on the return value of the liking API: Is this the case that the back-end server simply returns OK to indicate processing success, and then the front-end server increases the number of likes by 1 upon receipt of OK, or the back-end server returns an OK to indicate success, and returns the current number of likes of this object, and then the front-end server updates the number of likes on the page?
Of course, the back-end engineer is willing to implement the former. It is just to update gmt_modified and count using an update statement, and then return OK to have it done; otherwise, more work is required. How nice it will be if the back-end interface can return more data to the front-end server.
The time used for network communication between the server and database for queries completely subject to indexes is many times that for queries in the database, plus begin and commit, which is meant to double the query time.
A transaction should only be opened in the cases where it is required to guarantee atomicity, such as updating multiple tables.
Instead, it may be subject to another update statement, so that the user can feel the enthusiasm of other users during the period when the database begins to execute the update statement, and during the period when the update statement is executed until the select statement starts to be executed.
Discovering this problem, the back-end engineer considers what to do if the product manager who focuses on user experience thinks that the time window for the user to feel the enthusiasm is too long so as to result in a poor user experience, and wants to remove the time window from update to select.If it is opened for such a small requirement, it feels like using a sledge-hammer on a gnat. Is there any way to reduce the expenditure for the network communication in this transaction?If the time consumption in the transaction is reduced, the connection time will be reduced correspondingly, and the system will be able to bear more concurrent requests! If the four statements: begin, update, select and commit are written in the same stored procedure, the network communication times will be reduced from four to one, and the performance will be improved by 75%. The architect often tells us that our system is internet architecture, and if there is no particular reason, the business logic should be put in the application server, and the database is only used for storage but not business.; select @cnt as count; Because the Web application will involve the use of the connection pool when interacting with the database to get a connection before executing SQL statements, execute a great number of statements in the connection, and then return the connection to the connection pool, we basically do not have to worry about the case where the update and select statements are not in the same session as long as the code guarantees that the update and select statements are executed on the same connection.Is there really no way to have it done via a single query?There should be no particular reason to use stored procedures for such a small requirement.Tags: Adult Dating, affair dating, sex dating