sqlserver内存、会话、连接查询
1、连接查询
select * from sysprocesses where dbid in (select dbid from sysdatabases where name='dbname')
--或者
SELECT * FROM
[Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT
[DBID]
FROM
[Master].[dbo].[SYSDATABASES]
WHERE
NAME='dbname'
)
2、当前正在执行的sql查询
SELECT [Spid] = session_id ,
ecid ,
[Database] = DB_NAME(sp.dbid) ,
[User] = nt_username ,
[Status] = er.status ,
[Wait] = wait_type ,
[Individual Query] = SUBSTRING(qt.text,
er.statement_start_offset / 2,
( CASE WHEN er.statement_end_offset = -1
THEN LEN(CONVERT(NVARCHAR(MAX), qt.text))
* 2
ELSE er.statement_end_offset
END - er.statement_start_offset )
/ 2) ,
[Parent Query] = qt.text ,
Program = program_name ,
hostname ,
nt_domain ,
start_time
FROM sys.dm_exec_requests er
INNER JOIN sys.sysprocesses sp ON er.session_id = sp.spid
CROSS APPLY sys.dm_exec_sql_text(er.sql_handle) AS qt
WHERE session_id > 50 -- Ignore system spids.
AND session_id NOT IN ( @@SPID ) -- Ignore this current statement.
ORDER BY 1 ,
清理存储过程预编译等缓存、会话缓存、系统缓存、缓存区
DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE('All')
DBCC DROPCLEANBUFFERS
--内存使用情况
SELECT * FROM sys.dm_os_performance_counters
WHERE counter_name IN ('Target Server Memory (KB)','Total Server Memory (KB)') -- 内存状态
DBCC MemoryStatus --查看最小最大内存
SELECT
cfg.name AS [Name],
cfg.configuration_id AS [Number],
cfg.minimum AS [Minimum],
cfg.maximum AS [Maximum],
cfg.is_dynamic AS [Dynamic],
cfg.is_advanced AS [Advanced],
cfg.value AS [ConfigValue],
cfg.value_in_use AS [RunValue],
cfg.description AS [Description]
FROM
sys.configurations AS cfg --设置最小最大内存 sp_configure 'show advanced options', 1 go
sp_configure 'min server memory', 0
RECONFIGURE
GO sp_configure 'max server memory', 2147483647
RECONFIGURE
GO sp_configure 'max server memory', 256
RECONFIGURE
GO
sp_configure 'show advanced options', 0
CREATE proc [dbo].reclaimmemory --强制释放内存 as begin DBCC FREEPROCCACHE
DBCC FREESESSIONCACHE
DBCC FREESYSTEMCACHE('All')
DBCC DROPCLEANBUFFERS exec sp_configure 'max server memory', 256
EXEC ('RECONFIGURE' ) WAITFOR DELAY '00:00:05' EXEC sp_configure 'max server memory', 2147483647
EXEC ('RECONFIGURE' )
GO end
sqlserver内存、会话、连接查询的更多相关文章
- SQLServer数据库之连接查询
SQLServer数据库之连接查询 表的连接查询的几种方法介绍: inner join on内连接,left join on 左连接 , rigth join on 右连接, full join on ...
- SQLServer多表连接查询
双表内部连接查询 select wName,dName from DepartMent,Worker where DepartMent.dID=Worker.did select wName,dNam ...
- SQL多表连接查询以及mysql数据库、sqlserver数据库常见不同点
mysql数据库表及数据准备语句: USE test; DROP TABLE IF EXISTS `teacher_table`; DROP TABLE IF EXISTS `student_tabl ...
- 图解SQLSERVER联合查询和连接查询的区别
相信很多人都会用SQLSERVER联合查询和连接查询,但是用起来不一定都得心应手,对于其中的原理可能就模糊不清了,要想很牢固地掌握和运用SQL联合查询和连接查询机制,必须对其根本原理有很清晰认识, ...
- SQLServer SQL连接查询深度探险(摘录
SQL连接查询深度探险[摘录] 测试环境: Windows XP Profession MySQL 5.0.45 Oracle 9i DB2 UDB 9.1 测试的SQL脚本如下:此脚本适合MySQL ...
- 11-04 SQLserver基础--连接查询、联合查询、索引
一.子查询补充: Exists的用法: select*from haha where exists(select*from bumen where bumen.code=haha.bumen,and ...
- SQLServer连接查询之Cross Apply和Outer Apply的区别及用法
https://blog.csdn.net/wikey_zhang/article/details/77480118 先简单了解下cross apply的语法以及会产生什么样的结果集吧! 示例表: S ...
- SQLserver基础--连接查询、联合查询、索引
一.子查询补充: Exists的用法:select*from haha where exists(select*from bumen where bumen.code=haha.bumen,and b ...
- 010.简单查询、分组统计查询、多表连接查询(sql实例)
-------------------------------------day3------------ --添加多行数据:------INSERT [INTO] 表名 [(列的列表)] --SEL ...
随机推荐
- Prometheus入门到放弃(1)之Prometheus安装部署
规划: IP 角色 版本 10.10.0.13 prometheus-server 2.10 10.10.0.11 node_exporter 0.18.1 10.10.0.12 node_expor ...
- CentOS7 搭建 Consul 集群
环境准备: ssh shell工具: 远程连接 三个CentOS示例: 部署集群 配置好各个实例之间的网络访问,以及ssh免密登录. 下载&上传: 1.下载 Consul: Download ...
- hashCode和identifyHashCode的区别
API: System类提供一个identifyHashCode(Object o)的方法,该方法返回指定对象的精确hashCode值,也是根据该对象的地址计算得到的HashCode值.当某个类的ha ...
- (6)Spring Boot web开发 --- 错误处理页面
文章目录 处理时间(`Date`)类型 thymeleaf 页面拼接字符串 映射路径占位符 使用 put.delete 方法 错误处理机制 处理时间(Date)类型 Spring Boot 进行参数绑 ...
- P5200 [USACO19JAN]Sleepy Cow Sorting
P5200 [USACO19JAN]Sleepy Cow Sorting 题目描述 Farmer John正在尝试将他的N头奶牛(1≤N≤10^5),方便起见编号为1…N,在她们前往牧草地吃早餐之前排 ...
- Python-05-字符串格式化
一.百分号方式 %[(name)][flags][width].[precision]typecode (name) 可选,用于选择指定的key flags 可选,可供选择 ...
- Ubuntu 18.04安装arm-linux-gcc交叉编译器
Ubuntu 18.04安装arm-linux-gcc交叉编译器
- DataSource配置
一.JDBC Jar依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifac ...
- 织梦安全防护:禁止uploads、data、templets执行脚本
下面介绍下如何针对uploads.data.templets做PHP脚本限制:对uploads.data.templets 三个目录做执行php脚本限制,就算被上传了木马文件到这些文件夹,也是无法运行 ...
- 怎样获取当前页面框架的数量(即iframe和frame的数量)
需要使用window.length, 或者window.frames.length; 如果页面中不包含frame和iframe元素, 则返回0; window.length === window.fr ...