sql SQL查询从kstat收集的数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql SQL查询从kstat收集的数据相关的知识,希望对你有一定的参考价值。

-- Create a table containing a timestamp column and two columns with
-- normalized ratio between available memory (availrmem) and kernel pages
-- relative to total number of system pages (pagestotal). 
-- We do not GROUP BY here, because we want to have each line from input
-- represented in output.
-- Input data was originally produced with kspgs tool.
SELECT
	-- The `-6 hours` here tells SQLite to subtract 6 hours from the
	-- timestamp, which will adjust for timezone delta between GMT
	-- and Central Timezone. Adjust this number for correct timezone.
	strftime('%s', timestamp, 'unixepoch','-6 hours') as timestamp,
	ROUND((CAST(availrmem AS double) / CAST(pagestotal AS double)
	- subq.avgAvRatio) / subq.sdAvRatio, 4) as "Z-score Ratio Available Total",
	ROUND((CAST(pp_kernel AS double) / CAST(pagestotal AS double)
	- subq.avgKernRatio) / subq.sdKernRatio, 4) as "Z-score Ratio Kernel Total"
	FROM (
		SELECT
			avg(availrmem / CAST(pagestotal AS double)) as avgAvRatio,
			stdev(availrmem / CAST(pagestotal AS double)) as sdAvRatio,
			avg(pp_kernel / CAST(pagestotal AS double)) as avgKernRatio,
			stdev(pp_kernel / CAST(pagestotal AS double)) as sdKernRatio
			FROM mem
	) subq, mem

以上是关于sql SQL查询从kstat收集的数据的主要内容,如果未能解决你的问题,请参考以下文章

mysql慢查询

从 VB.NET 复选框选项构建 SQL 查询时遇到问题

在 SQL 中存储大量传感器数据,优化查询性能

mongodb 跟踪SQL语句及慢查询收集

让 SQL 查询更快更好

从sql中返回的查询值的子查询?