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. python基础===将json转换为dict的办法

    首先json是字符串. 大家都知道,字符串是用来传递信息的.json字符串实际上就是一种规定了格式的字符串, 通过这种格式,我们可以在不同的编程语言之间互相传递信息,比如我们可以把javascript ...

  2. MongoDB的安装配置、基本操作及Perl操作MongoDB

    MongoDB的安装配置.基本操作及Perl操作MongoDB http://www.myhack58.com/Article/60/63/2014/42353.htm

  3. 访问dubbo没有权限,通过ip进行跳转服务器,并通过有权限服务器代理访问

    #启动ip跳转 echo 1 > /proc/sys/net/ipv4/ip_forward vi /etc/sysctl.conf net.ipv4.ip_forward =1 sysctl ...

  4. HDU 5116 Everlasting L

    题目链接:HDU-5116 题意:给定若干个整数点,若一个点集满足P = {(x, y), (x + 1, y), . . . , (x + a, y), (x, y + 1), . . . , (x ...

  5. 10 个打造 React.js App 的最佳 UI 框架

    10 个打造 React.js App 的最佳 UI 框架 在本文中,我们将分享一些助你打造 React.js App 最佳的 UI 框架.它们具备你所需要的基本 React 组件,以及易用的 API ...

  6. 如何在datepicker滚动完毕后触发事件去获得日期

    本来以为这件事情应该需要借助datepicker的委托来处理的,但是并没有找到此空间的委托. 其实最最简单的做法就是在IB中将次控件connect到一个Action上. 经过测试,当datepicke ...

  7. Activiti如何替换已部署流程图

    首先交代下背景:我们有一个已经上线的activiti工作流系统,对于流程图的操作已经封装好部署,查看,删除的接口.此时客户提出要修改个别流程图里的节点名称. 我的第一个想法就是本地修改流程图bpmn文 ...

  8. window.screen.height和window.screen.availHeight和document.body.clientHeight和document.documentElement.clientHeight

    说这几个属性前 我说一下我的设备 我的设备有两个,一个高度为1080的显示器,一个高度为800的电脑 第一种:window.screen.height 这个方法是获取用户电脑屏幕的高度,是不关浏览器或 ...

  9. Matlab处理数据导出Paraview可读的vtk文件(二)

    由于我在用SPH方法仿真时用的是FORTRAN语言,并且没有找到直接输出vtk文件的代码,因此偷懒通过MATLAB转换一下数据. 用到的Matlab子程序可通过一下链接找到. Matlab处理数据导出 ...

  10. 【转】kubernetes 中 deployment 支持哪些键值

    这个比较全,可以参考 ================= https://www.addops.cn/post/kubernetes-deployment-fileds.html ========== ...