Posted by Padma Chitturi in Uncategorized. Leave a Comment

Hi Folks,

It has been such a long time that I have written on SQL Server.  Let’s go for a trip on SQL architecture and few things which really might interest us.

Every one of us write queries and expect SQL to return results within no time. Had any of us questioned yourself, what’s the mechanism inside SQL that is serving the requests of users and making us happy !!

Well, let’s see the architecture of SQL and how it behaves when we submit a query.

SQL Server Architecture and Life Cycle of a Query:

The above picture clearly depicts that SQL Engine is split into two main engines: Relational Engine and Storage Engine.

The Relational engine is query processor as its functionality is query optimization and execution. Confused with the words optimization and execution ? Don’t worry, will discuss on that.

Storage engine– the name itself indicates that it is for managing SQL Server memory.

Buffer Pool:  This is the major component as it holds the SQL Server memory. The buffer pool contains plan cache and data cache. Plan cache is the one which is the storage area for execution plans and data cache holds the data.

What happens when we submit SELECT query ?

SNI (SQL Server Network interface): When we submit a query, we are actually interacting with the SQL engine, which means that some connection has been established between client (user) and server to have communication. SNI is a protocol layer which establishes connection between client and server. The connection is responsible for sending requests and receiving data.

Command Parser: This component in relational engine checks the syntax of the query and returns any errors that would reach the client via protocol layer. If the syntax is correct, query plan will be generated and will be checked against the plan cache. If the plan already exists in plan cache, it will be reused. However, if it’s not found, query tree would be generated (each node in the tree represents operation to be preformed) and this will be passed as input to query optimizer.

Optimizer: It is the major component in SQL. It finds out multiple ways to execute a query and finds out the best plan (with low cost and that would take less time to execute). Finding out the efficient plan brings out the capability of optimizer.

Query Executor: The name itself is self-explanatory. It executes the query plan i.e executes each step in the plan, interacts with storage engine to retrieve/modify data.

In order to access data, query executor interacts with storage engine via OLEDB to access methods.

Access Methods: It contains several methods to retrieve the data. This actually sends the request to buffer manager.

Buffer Manager: It manages the buffer pool. If some records need to be fetched, buffer manager checks data cache and the data pages are already cached, they would be fetched and passed back to access methods. If the data pages are not cached, they would be read from the disk, put it on data cache and then the results would be passed to access methods.

Transaction Manager: This has two major components- Lock manager and Log manager. The Lock manager provides concurrency to the data and maintains isolation levels. The Log manager writes the changes to the transaction log.  As and when we hear about log and lock manager we would be landing up with many questions. Let’s take a break here and have deep dive when I write about  transaction logs and isolation levels.

What happens when a SQL Query runs?的更多相关文章

  1. jstl中的sql:query标签获取的结果如何格式化输出

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  2. .net连接DB2的异常SQL0666 - SQL query exceeds specified time limit or storage limit.错误处理

    SQL0666 - SQL query exceeds specified time limit or storage limit. 原因:查询超时 解决办法: set the DbCommand.C ...

  3. NHibernate系列文章二十六:NHibernate查询之SQL Query查询(附程序下载)

    摘要 NHibernate在很早的版本就提供了SQL Query(原生SQL查询),对于很复杂的查询,如果使用其他的查询方式实现比较困难的时候,一般使用SQL Query.使用SQL Query是基于 ...

  4. Freebie - Utility Form: Generate Excel Report From SQL Query In Oracle Forms 6i And 11g

    Sharing a form to generate Excel file report from SQL query in Oracle Forms. This form can be used i ...

  5. jasper ireport create a report with parameters without sql query

    I'm new in jasper ireport , and I want to know if it is possible to create a report only with static ...

  6. 使用JSTL的sql:query标签制作分页查询遇到NoSuchFieldError: deferredExpression

    参考:http://hi.baidu.com/desyle/item/4fe650265792d7182a0f1c33 症状: 如题所述,代码如下 <sql:query var="re ...

  7. REP-20147 Cannot implement column link for this detail SQL query. Converting to group link.

    注:本文为原创,作为学习交流使用,转载请标明作者及出处,作者保留追究法律责任的权力. Lumen Su lzsu1989#gmail.com (#=@) www.cnblogs.com/lzsu198 ...

  8. EntityFramework 学习 一 Execute Native SQL Query

    SQL query for entity types: using (var ctx = new SchoolDBEntities()) { var studentList = ctx.Student ...

  9. Entity Framework Tutorial Basics(39):Raw SQL Query

    Execute Native SQL Query You can execute native raw SQL query against the database using DBContext. ...

随机推荐

  1. 2015多校第6场 HDU 5358 First One 枚举,双指针

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5358 题意:如题. 解法:观察式子发现,由于log函数的存在,使得这个函数的值域<=34,然后我 ...

  2. Pylot网站Web服务器性能和负载压力测试-适用Windows可绘制图表

    为了能够准确地评估网站服务器对网络流量的承受能力,我们一般会采取模拟网站用户访问,通过不断地增加并发数,延长访问时长,从而最终得出网站Web服务器的性能和负载能力.当然也可以通过Web压力测试,来完善 ...

  3. .net页面实时预览图片

    <script type="text/javascript"> //获取上传图片的本地路径 function getPath(obj){ if(obj) { if(na ...

  4. 关于IE8版本提示“不支持‘trim’此属性或者方法”的解决办法。转摘雨网络

    在js文件的前面加 String.prototype.trim = function () { return Trim(this); }; function LTrim(str) { var i; f ...

  5. ImportError: No module named etree.ElementTree

    ImportError: No module named etree.ElementTree 排查N久,才发现是因为文件名是xml.py的缘故,文件名一定不要用关键词.....

  6. (error) DENIED Redis is running in protected mode because protected mode is enabled

    在通过Java程序链接配置好的redis服务时出现 DENIED Redis is running in protected mode because protected mode is enable ...

  7. sql 触发器 游标

    在数据库中,删除一条记录的同时想要删除另一个表里的数据,这时我们可以选择使用触发器.触发器主要是通过事件进行触发被自动调用执行的,而存储过程可以通过存储过程的名称被调用.触发器是当对某一个表进行操作. ...

  8. eclipse 查看jdk源码

    eclipse中引入jdk源码的设置:  设置: 1.点 "window"-> "Preferences" -> "Java" ...

  9. Java实现蛇形矩阵

    public class Solution { //下x++ 左y-- 上x-- 右y++ public void prints(int n) { int[][] mp = new int[n][n] ...

  10. 洛谷P1908 逆序对 [权值线段树]

    题目传送门 逆序对 题目描述 猫猫TOM和小老鼠JERRY最近又较量上了,但是毕竟都是成年人,他们已经不喜欢再玩那种你追我赶的游戏,现在他们喜欢玩统计.最近,TOM老猫查阅到一个人类称之为“逆序对”的 ...