Skip to content

Instantly share code, notes, and snippets.

View marco-carvalho's full-sized avatar
🎯
Focusing

Marco Carvalho marco-carvalho

🎯
Focusing
View GitHub Profile
;WITH task_space_usage AS (
-- SUM alloc/delloc pages
SELECT session_id,
request_id,
SUM(internal_objects_alloc_page_count) AS alloc_pages,
SUM(internal_objects_dealloc_page_count) AS dealloc_pages
FROM sys.dm_db_task_space_usage WITH (NOLOCK)
WHERE session_id <> @@SPID
GROUP BY session_id, request_id
)
{
"editor.largeFileOptimizations": false,
"editor.detectIndentation": true,
"editor.insertSpaces": true,
"editor.minimap.enabled": false,
"editor.rulers": [80,120],
"editor.scrollBeyondLastLine": false,
"editor.tabSize": 4,
"explorer.autoReveal": true,
"explorer.confirmDelete": false,
use master
SELECT
r.session_id,r.command,CONVERT(NUMERIC(6,2),r.percent_complete) AS [Percent Complete],
CONVERT(VARCHAR(20),DATEADD(ms,r.estimated_completion_time,GetDate()),20) AS [ETA Completion Time],
CONVERT(NUMERIC(10,2),r.total_elapsed_time/1000.0/60.0) AS [Elapsed Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0) AS [ETA Min],
CONVERT(NUMERIC(10,2),r.estimated_completion_time/1000.0/60.0/60.0) AS [ETA Hours],
CONVERT(
VARCHAR(1000),
with indexcols as (
select
object_id as table_id,
index_id,
name as index_name,
(
select case keyno when 0 then null else colid end as [data()]
from sys.sysindexkeys as k
where k.id = i.object_id
and k.indid = i.index_id
SELECT
i.name,
sts.last_user_seek,
sts.last_user_scan,
sts.user_updates AS [Total Writes] ,
sts.user_seeks + sts.user_scans + sts.user_lookups AS [Total Reads] ,
sts.user_updates / iif(sts.user_seeks + sts.user_scans + sts.user_lookups > 0, sts.user_seeks + sts.user_scans + sts.user_lookups * 1.0, 1) AS [Difference],
'DROP INDEX [' + i.name + '] ON [' + OBJECT_SCHEMA_NAME(o.object_id) + '].[' + OBJECT_NAME(o.object_id) + ']'
from sys.indexes i
join sys.objects o on o.object_id = i.object_id
SELECT
id.[statement]
,id.[equality_columns]
,id.[inequality_columns]
,id.[included_columns]
,gs.[unique_compiles] AS [UniqueCompiles]
,gs.[user_seeks] AS [UserSeeks]
,gs.[avg_total_user_cost] AS [AvgTotalUserCost] -- Average cost of the user queries that could be reduced by the index in the group.
,gs.[avg_user_impact] AS [AvgUserImpact] -- The value means that the query cost would on average drop by this percentage if this missing index group was implemented.
,gs.[user_seeks] * gs.[avg_total_user_cost] * (gs.[avg_user_impact] * 0.01) AS [IndexAdvantage]
--DBCC FREEPROCCACHE
--PERFORMANCE DE TODAS AS CONSULTAS EXECUTADAS
select
object_schema_name(qt.objectid, qt.dbid) + '.' + object_name(qt.objectid, qt.dbid) as db_name,
substring(
qt.text,
qs.statement_start_offset/2 + 1,
(
case
for k in $(git branch --sort=committerdate --remote | grep -o -P "(?<=origin\/)[^ ]+"); do
if [[ ! $(git log -1 --since='6 month ago' -s origin/$k) ]]; then
git push origin -d $k;
fi;
done;
const childProcess = require("child_process");
const pjson = require('./package.json');
const getDependencies = () => {
const response = [];
const { dependencies } = pjson;
console.log(dependencies)
if (!dependencies) {
console.log("Package.json without dependencies.");
return;