Como verificar os logs de application pool shutdown e aumentar o idle timeout

Para verificar os logs de application pool shutdown, no Event Viewer do Windows, filtre os logs por source “WAS”.

Para aumentar o idle timeout de um application pool, no IIS Manager selecione Application Pools, selecione o pool que deseja configurar, clique em Advanced Settings e configure um valor maior para a propriedade Idle Time-out (minutes).


Como listar tabelas e Stored Procedures não utilizadas


USE banco

SELECT t.[name] AS 'Table'
    ,SUM(i.user_seeks + i.user_scans + i.user_lookups) AS 'Total accesses'
    ,SUM(i.user_seeks) AS 'Seeks'
    ,SUM(i.user_scans) AS 'Scans'
    ,SUM(i.user_lookups) AS 'Lookups'
FROM sys.dm_db_index_usage_stats i
RIGHT JOIN sys.tables t
    ON (t.object_id = i.object_id)
GROUP BY i.object_id
ORDER BY [Total accesses]

Stored Procedures

Note que a view dm_exec_procedure_stats retorna somente as procedures que estão em cache. Portanto, procedures que foram executadas recentemente mas saíram do cache podem aparecer como não executadas. Indico analisar várias vezes antes de apagar.

USE banco

SELECT sc.[name]
FROM sys.procedures AS p
JOIN sys.schemas AS sc
    ON p.[schema_id] = sc.[schema_id]
LEFT JOIN sys.dm_exec_procedure_stats AS st
    ON p.[object_id] = st.[object_id]
ORDER BY st.last_execution_time

Why should casting be avoided?

A cast (obviously enough) means you’re converting something from one type to another. When/if you do that, it raises the question “Why?” If you really want something to be a particular type, why didn’t you define it to be that type to start with? That’s not to say there’s never a reason to do such a conversion, but anytime it happens, it should prompt the question of whether you could re-design the code so the correct type was used throughout.