Some Query Plan

use DBName;
go

--  View the plan, along with a FreeProcCache command
--  SQL Server 2008+ only
select  deqs.plan_handle
      , deqs.sql_handle
      , execText.text
      , QP.query_plan
      , 'DBCC FREEPROCCACHE (' + convert(varchar(1000), deqs.plan_handle, 1) + ');' as DropStatement
from    sys.dm_exec_query_stats                            deqs
        cross apply sys.dm_exec_sql_text(deqs.plan_handle) as execText
        cross apply sys.dm_exec_query_plan(plan_handle) as QP
where   execText.text like '%SEARCH_STRING%';

--  Use Counts for plans
select  CP.usecounts
      , CP.cacheobjtype
      , CP.objtype
      , ST.[text]
from    sys.dm_exec_cached_plans                      as CP
        cross apply sys.dm_exec_sql_text(plan_handle) as ST
        cross apply sys.dm_exec_query_plan(plan_handle) as QP
where   ST.[text] like '%SEARCH_STRING%';

select  D1.name
      , QText.text                                                                                 as TSQL_Text
      , cast(cast(QS.total_worker_time as decimal) / cast(QS.execution_count as decimal) as int)   as cpu_per_execution
      , cast(cast(QS.total_logical_reads as decimal) / cast(QS.execution_count as decimal) as int) as logical_reads_per_execution
      , cast(cast(QS.total_elapsed_time as decimal) / cast(QS.execution_count as decimal) as int)  as elapsed_time_per_execution
      , QS.creation_time
      , QS.execution_count
      , QS.total_worker_time                                                                       as total_cpu_time
      , QS.max_worker_time                                                                         as max_cpu_time
      , QS.total_elapsed_time
      , QS.max_elapsed_time
      , QS.total_logical_reads
      , QS.max_logical_reads
      , QS.total_physical_reads
      , QS.max_physical_reads
      , QPlan.query_plan
      , CP.cacheobjtype
      , CP.objtype
      , CP.size_in_bytes
from    sys.dm_exec_query_stats                          as QS
        cross apply sys.dm_exec_sql_text(QS.plan_handle) as QText
        cross apply sys.dm_exec_query_plan(QS.plan_handle) as QPlan
        inner join sys.databases            as D1
                   on QText.dbid = D1.database_id
        inner join sys.dm_exec_cached_plans as CP
                   on CP.plan_handle = QS.plan_handle
where   QText.text like '%usp_GlobalCashFlowRefresh%';
"""
postgresverification.py

The script performs the following:
1. Reads the PostgreSQL configuration file
2. Outputs the current values of the settings to the console
    a. If the setting is not set, then "Not Set" is displayed
    b. If the setting is commented out, then "Commented Out" is displayed
3. Appends the results to a JSON file

The results are appended to the file in JSON format.
The file is created if it doesn't exist.

Author: Rudy Rodarte
Date: 2023-09-25

Usage: python postgresverification.py [path_to_postgresql.conf]
"""

"""
mongodbverification.py

The script performs the following:
1. Reads the MongoDB configuration file
2. Outputs the current values of the settings to the console
  a. If the setting is not set, then "Not Set" is displayed
  b. If the setting is commented out, then "Commented Out" is displayed
3. Appends the results to a JSON file

The results are appended to the file in JSON format. 
The file is created if it doesn't exist.

Author: Rudy Rodarte
Date: 2023-09-25

Usage: python mongodbverification.py [path_to_mongod.conf]
"""

By Rudy