Simple Analysis of SQL Server Principle

(1) The client sqlserver network interface passes a network protocol (can be shared memory: simple and high-speed, the client and sql server are connected by default on the same computer; TCP/IP: the most commonly used protocol for accessing sql server, the client The terminal specifies the ip address and port number to connect to the sql server; named pipe: the named pipe and the TCP/IP protocol are similar in architecture and are designed for the local area network, and the speed will be slower in the wide area network; VIA: virtual interface adapter, It is a protocol that allows two systems to perform high-performance communication, requiring the use of special hardware and dedicated connections at both ends of the communication) to establish a connection with the service's SNI, and then create a connection through the network protocol connection and the TDS port, and Through this connection, sqlserver sends select statements in the form of TDS messages.

(2) The SNI of the sql server unpacks the TDS message, reads the select statement, and then sends the sql command to the command parser.

(3) The command parser checks whether there is a query plan that matches the received statement and is available in the plan cache of the buffer pool. If it is not found, the command parser generates a query tree based on the select statement, and then converts the The query tree is passed to the query optimizer to generate a query plan.

(4) Since this query command is very simple, the query optimizer only generates a "zero-overhead" query plan (ie, "normal query plan") in the pre-optimization stage, and the query optimizer sends the created query plan to the query executor executes.

(5) When the query executor executes the query plan, it first determines what data needs to be read to complete the query plan, and then sends an access data request to the access method in the storage engine through the OLE DB interface.

(6) In order to complete the query executor's request, the access method needs to read a data page from the database and ask the buffer manager to provide this data page.

(7) The buffer manager checks whether the data page exists in the data cache. If the page does not exist in the data cache, the buffer manager first obtains the data page from the disk, then stores it in the cache, and uploads it to the cache. back to the access method.

(8) Finally, the access method passes the result set to the relational engine, and the relational engine sends the result set to the client.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326146726&siteId=291194637