こんにちは、ねこです。

自称プログラマのおばちゃんのブログです。いろいろあるよねぇ~。

MCSA SQL Server 2016 /70-762/DMs 覚えらんねェー!

2019-12-27 07:54:38 | プログラム 勉強

【DMSとモニタリングに関する問題】

赤字は過去問から。

sys.dm_os_wait_stats
Returns information about all the waits encountered by threads that executed. You can use this aggregated view to diagnose performance issues with SQL Server and also with specific queries and batches.
実行したスレッドが遭遇したすべての待機に関する情報を返します。 この集計ビューを使用して、SQL Serverと特定のクエリおよびバッチのパフォーマンスの問題を診断できます。
*#48--[You need to identify previous situations where a modification has prevented queries from selecting data in tables.]

*#163--[You must monitor and optimize the SQL Server to maximize throughput, response time, and overall SQL performance. You need to examine delays in executed threads, including errors with queries and batches.]

A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

G
Create a SQL Profiler trace.
#49--[You need to monitor the SQL environment and capture the information about the processes that are causing the deadlocks. Captured information must be viewable as the queries are running.]
A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

F
sys.dm_exec_sessions
Returns one row per authenticated session on SQL Server. sys.dm_exec_sessions is a server-scope view that shows information about all active user connections and internal tasks. This information includes client version, client program name, client login time, login user, current session setting, and more. Use sys.dm_exec_sessions to first view the current system load and to identify a session of interest, and then learn more information about that session by using other dynamic management views or dynamic management functions.
SQL Serverで認証されたセッションごとに1行を返します。 sys.dm_exec_sessionsは、すべてのアクティブなユーザー接続と内部タスクに関する情報を表示するサーバースコープビューです。 この情報には、クライアントバージョン、クライアントプログラム名、クライアントログイン時間、ログインユーザー、現在のセッション設定などが含まれます。 sys.dm_exec_sessionsを使用して、最初に現在のシステム負荷を表示し、目的のセッションを特定してから、他の動的管理ビューまたは動的管理機能を使用して、そのセッションに関する詳細情報を学習します。
*#50--[You must monitor the SQL Server instances in real time and optimize the server to maximize throughput, response time, and overall SQL performance.]
A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

B
Activity Monitor session in Microsoft SQL Management Studio.
*#76 and #36[You need to evaluate schema locking issues, plan cache memory pressure points, and backup I/O problems.]
A. a System Monitor report
B. a sys.dm_tran_database_transaction dynamic management view query
C. an Extended Events session that uses Query Editor
D. an Activity Monitor session in Microsoft SQL Management Studio.

D
Create an Extended Event.
*#51--[You need to ensure that the performance of each instance is consistent for the same queried and query plans.]
A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

H
Create a Performance Monitor Data Collector Set
*#52--[You need to collect query performance data while minimizing the performance impact on the SQL Server.]
A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

C
sys.dm_os_memory_objects
Returns memory objects that are currently allocated by SQL Server. You can use sys.dm_os_memory_objects to analyze memory use and to identify possible memory leaks.
SQL Serverによって現在割り当てられているメモリオブジェクトを返します。 sys.dm_os_memory_objectsを使用して、メモリ使用量を分析し、メモリリークの可能性を特定できます。
*#53--[You need to create a baseline set of metrics to report how the computer running SQL Server operates under normal load. The baseline must include the resource usage associated with the server processes.]
A. Create a sys.dm_os_waiting_tasks query.
B. Create a sys.dm_exec_sessions query.
C. Create a PerformanceMonitor Data Collector Set.
D. Create a sys.dm_os_memory_objects query.
E. Create a sp_configure "˜max server memory' query.
F. Create a SQL Profiler trace.
G. Create a sys.dm_os_wait_stats query.
H. Create an Extended Event.

D


SET SHOWPLAN_ALL ON
*#149[You need to identify the cause by using detailed information about the Transact-SQL statements in the queries. The Transact-SQL statements must not run as part of the analysis.]
クエリ内のTransact-SQLステートメントに関する詳細情報を使用して、原因を特定する必要があります。 Transact-SQLステートメントは、分析の一部として実行しないでください。
SET SHOWPLAN_TEXT ON
*#171[You need to identify the cause by using detailed information about the Transact-SQL statements in the queries. The Transact-SQL statements must not run as part of the analysis.]
クエリ内のTransact-SQLステートメントに関する詳細情報を使用して、原因を特定する必要があります。 Transact-SQLステートメントは、分析の一部として実行しないでください。
sys.dm_exec_query_stats
*#33[You need to determine which query uses the most cumulative CPU.どのクエリが最も累積的なCPUを使用するかを決定する必要があります。]
(答)sys.dm_exec_query_stats と highest_cpu_queries.total_worker_time DESC

Returns aggregate performance statistics for cached query plans in SQL Server. The view contains one row per query statement within the cached plan, and the lifetime of the rows are tied to the plan itself. When a plan is removed from the cache, the corresponding rows are eliminated from this view.
SQL Serverのキャッシュされたクエリプランの集計パフォーマンス統計を返します。 ビューには、キャッシュされたプラン内のクエリステートメントごとに1つの行が含まれ、行の有効期間はプラン自体に関連付けられています。 プランがキャッシュから削除されると、対応する行はこのビューから削除されます。










ここから先はまだプレップで見たことがないです。
sys.dm_external_script_execution_stats
Returns one row for each type of external script request. The external script requests are grouped by the supported external script language. One row is generated for each registered external script functions. Arbitrary external script functions are not recorded unless sent by a parent process, such as
外部スクリプトリクエストのタイプごとに1行を返します。 外部スクリプトリクエストは、サポートされている外部スクリプト言語ごとにグループ化されます。 登録済みの外部スクリプト関数ごとに1行が生成されます。 次のような親プロセスから送信されない限り、任意の外部スクリプト関数は記録されません。
sys.dm_external_script_requests
Returns a row for each active worker account that is running an external script.
外部スクリプトを実行しているアクティブなワーカーアカウントごとに行を返します。
sys.dm_exec_cached_plan_dependent_objects
Returns a row for each Transact-SQL execution plan, common language runtime (CLR) execution plan, and cursor associated with a plan.
各Transact-SQL実行プラン、共通言語ランタイム(CLR)実行プラン、およびプランに関連付けられたカーソルの行を返します。
sys.dm_exec_cached_plans
Returns a row for each query plan that is cached by SQL Server for faster query execution. You can use this dynamic management view to find cached query plans, cached query text, the amount of memory taken by cached plans, and the reuse count of the cached plans.
クエリの実行を高速化するために、SQL Serverによってキャッシュされる各クエリプランの行を返します。 この動的管理ビューを使用して、キャッシュされたクエリプラン、キャッシュされたクエリテキスト、キャッシュされたプランが使用するメモリ量、キャッシュされたプランの再利用カウントを検索できます。
sys.dm_exec_compute_node_errors
Returns errors that occur on PolyBase compute nodes.
PolyBase計算ノードで発生したエラーを返します。
sys.dm_exec_compute_node_status
Holds additional information about the performance and status of all PolyBase nodes. Lists one row per node.
すべてのPolyBaseノードのパフォーマンスとステータスに関する追加情報を保持します。 ノードごとに1行をリストします。
sys.dm_exec_compute_nodes
Holds information about nodes used with PolyBase data management. It lists one row per node.
PolyBaseデータ管理で使用されるノードに関する情報を保持します。 ノードごとに1行がリストされます。
sys.dm_exec_connections
Returns information about the connections established to this instance of SQL Server and the details of each connection. Returns server wide connection information for SQL Server. Returns current database connection information for SQL Database.
SQL Serverのこのインスタンスに対して確立された接続に関する情報と各接続の詳細を返します。 SQL Serverのサーバー全体の接続情報を返します。 SQL Databaseの現在のデータベース接続情報を返します。
sys.dm_exec_cursors
Returns information about the cursors that are open in various databases.
さまざまなデータベースで開いているカーソルに関する情報を返します。
sys.dm_exec_describe_first_result_set
This dynamic management function takes a Transact-SQL statement as a parameter and describes the metadata of the first result set for the statement.
この動的管理関数は、Transact-SQLステートメントをパラメーターとして受け取り、ステートメントの最初の結果セットのメタデータを記述します。
sys.dm_exec_describe_first_result_set_for_object
This dynamic management function takes an @object_id as a parameter and describes the first result metadata for the module with that ID. The @object_id specified can be the ID of a Transact-SQL stored procedure or a Transact-SQL trigger. If it is the ID of any other object (such as a view, table, function, or CLR procedure), an error will be specified in the error columns of the result.
この動的管理関数は、パラメータとして@object_idを受け取り、そのIDを持つモジュールの最初の結果メタデータを記述します。 指定された@object_idは、Transact-SQLストアドプロシージャまたはTransact-SQLトリガーのIDです。 他のオブジェクト(ビュー、テーブル、関数、CLRプロシージャなど)のIDである場合、結果のエラー列にエラーが指定されます。
sys.dm_exec_distributed_request_steps
Holds information about all steps that compose a given PolyBase request or query. It lists one row per query step.
特定のPolyBaseリクエストまたはクエリを構成するすべてのステップに関する情報を保持します。 クエリステップごとに1行がリストされます。
sys.dm_exec_distributed_requests
Holds information about all requests currently or recently active in PolyBase queries.
PolyBaseクエリで現在または最近アクティブなすべてのリクエストに関する情報を保持します。
sys.dm_exec_distributed_sql_requests
Holds information about all SQL query distributions as part of a SQL step in the query. This view shows the data for the last 1000 requests; active requests always have the data present in this view.
クエリのSQLステップの一部として、すべてのSQLクエリ分布に関する情報を保持します。 このビューには、過去1000件のリクエストのデータが表示されます。 アクティブなリクエストには、常にこのビューにデータが存在します。
sys.dm_exec_dms_services
Holds information about all of the DMS services running on the PolyBase compute nodes. It lists one row per service instance.
PolyBase計算ノードで実行されているすべてのDMSサービスに関する情報を保持します。 サービスインスタンスごとに1行がリストされます。
sys.dm_exec_dms_workers
Holds information about all workers completing DMS steps.This view shows the data for the last 1000 requests and active requests; active requests always have the data present in this view.
DMSステップを完了するすべてのワーカーに関する情報を保持します。このビューには、最新の1000リクエストとアクティブリクエストのデータが表示されます。 アクティブなリクエストには、常にこのビューにデータが存在します。
sys.dm_exec_external_operations
Captures information about external PolyBase operations.
外部PolyBase操作に関する情報をキャプチャします。
sys.dm_exec_external_work
Returns information about the workload per worker, on each compute node.
各計算ノードで、ワーカーごとのワークロードに関する情報を返します。
sys.dm_exec_function_stats
Returns aggregate performance statistics for cached functions. The view returns one row for each cached function plan, and the lifetime of the row is as long as the function remains cached. When a function is removed from the cache, the corresponding row is eliminated from this view. At that time, a Performance Statistics SQL trace event is raised similar to sys.dm_exec_query_stats. Returns information about scalar functions, including in-memory functions and CLR scalar functions. Does not return information about table valued functions.
キャッシュされた関数の集計パフォーマンス統計を返します。 ビューは、キャッシュされた関数プランごとに1つの行を返します。行の有効期間は、関数がキャッシュされている限りです。 関数がキャッシュから削除されると、対応する行はこのビューから削除されます。 その時点で、sys.dm_exec_query_statsと同様のパフォーマンス統計SQLトレースイベントが発生します。 インメモリ関数やCLRスカラー関数などのスカラー関数に関する情報を返します。 テーブル値関数に関する情報を返しません。
sys.dm_exec_input_buffer
Returns information about statements submitted to an instance of SQL Server.
SQL Serverのインスタンスに送信されたステートメントに関する情報を返します。
sys.dm_exec_plan_attributes
Returns one row per plan attribute for the plan specified by the plan handle. You can use this table-valued function to get details about a particular plan, such as the cache key values or the number of current simultaneous executions of the plan.
プランハンドルで指定されたプランのプラン属性ごとに1行を返します。 このテーブル値関数を使用して、キャッシュキー値やプランの現在の同時実行数など、特定のプランに関する詳細を取得できます。
sys.dm_exec_procedure_stats
Returns aggregate performance statistics for cached stored procedures. The view returns one row for each cached stored procedure plan, and the lifetime of the row is as long as the stored procedure remains cached. When a stored procedure is removed from the cache, the corresponding row is eliminated from this view. At that time, a Performance Statistics SQL trace event is raised similar to sys.dm_exec_query_stats.
キャッシュされたストアドプロシージャの集計パフォーマンス統計を返します。 ビューは、キャッシュされたストアドプロシージャプランごとに1行を返します。行の有効期間は、ストアドプロシージャがキャッシュされている限りです。 ストアドプロシージャがキャッシュから削除されると、対応する行はこのビューから削除されます。 その時点で、sys.dm_exec_query_statsと同様のパフォーマンス統計SQLトレースイベントが発生します。
sys.dm_exec_query_memory_grants
Returns information about all queries that have requested and are waiting for a memory grant or have been given a memory grant. Queries that do not require a memory grant will not appear in this view. For example, sort and hash join operations have memory grants for query execution, while queries without an ORDER BY clause will not have a memory grant.
要求され、メモリ許可を待機している、またはメモリ許可が与えられているすべてのクエリに関する情報を返します。 メモリ許可を必要としないクエリは、このビューには表示されません。 たとえば、並べ替えおよびハッシュ結合操作にはクエリ実行用のメモリ許可がありますが、ORDER BY句のないクエリにはメモリ許可がありません。
sys.dm_exec_query_optimizer_info
Returns detailed statistics about the operation of the SQL Server query optimizer. You can use this view when tuning a workload to identify query optimization problems or improvements. For example, you can use the total number of optimizations, the elapsed time value, and the final cost value to compare the query optimizations of the current workload and any changes observed during the tuning process. Some counters provide data that is relevant only for SQL Server internal diagnostic use. These counters are marked as "Internal only."
SQL Serverクエリオプティマイザーの操作に関する詳細な統計を返します。 ワークロードを調整するときにこのビューを使用して、クエリ最適化の問題または改善点を特定できます。 たとえば、最適化の合計数、経過時間値、および最終コスト値を使用して、現在のワークロードのクエリ最適化とチューニングプロセス中に観察された変更を比較できます。 一部のカウンターは、SQL Serverの内部診断の使用にのみ関連するデータを提供します。 これらのカウンターは、「内部のみ」としてマークされています。
sys.dm_exec_query_optimizer_memory_gateways
Returns the current status of resource semaphores used to throttle concurrent query optimization.
同時クエリ最適化の調整に使用されるリソースセマフォの現在の状態を返します。
sys.dm_exec_query_plan
Returns the Showplan in XML format for the batch specified by the plan handle. The plan specified by the plan handle can either be cached or currently executing.
プランハンドルで指定されたバッチのShowplanをXML形式で返します。 プランハンドルで指定されたプランは、キャッシュすることも、現在実行中にすることもできます。
sys.dm_exec_query_parallel_workers
Returns worker availability information per node.
ノードごとにワーカーの可用性情報を返します。
sys.dm_exec_query_profiles
Monitors real time query progress while the query is in execution. For example, use this DMV to determine which part of the query is running slow. Join this DMV with other system DMVs using the columns identified in the description field. Or, join this DMV with other performance counters (such as Performance Monitor, xperf) by using the timestamp columns.
クエリの実行中にリアルタイムのクエリの進行状況を監視します。 たとえば、このDMVを使用して、クエリのどの部分の実行が遅いかを判断します。 説明フィールドで指定された列を使用して、このDMVを他のシステムDMVと結合します。 または、タイムスタンプ列を使用して、このDMVを他のパフォーマンスカウンター(パフォーマンスモニター、xperfなど)と結合します。
sys.dm_exec_query_resource_semaphores
Returns the information about the current query-resource semaphore status in SQL Server.
SQL Serverの現在のクエリリソースセマフォステータスに関する情報を返します。
sys.dm_exec_query_statistics_xml
Returns query execution plan for in-flight requests. Use this DMV to retrieve showplan XML with transient statistics.
実行中のリクエストのクエリ実行プランを返します。 このDMVを使用して、一時的な統計を含むshowplan XMLを取得します。
sys.dm_exec_query_stats
Returns aggregate performance statistics for cached query plans in SQL Server. The view contains one row per query statement within the cached plan, and the lifetime of the rows are tied to the plan itself. When a plan is removed from the cache, the corresponding rows are eliminated from this view.
SQL Serverのキャッシュされたクエリプランの集計パフォーマンス統計を返します。 ビューには、キャッシュされたプラン内のクエリステートメントごとに1つの行が含まれ、行の有効期間はプラン自体に関連付けられています。 プランがキャッシュから削除されると、対応する行はこのビューから削除されます。
sys.dm_exec_query_plan_stats
Returns the equivalent of the last known actual execution plan for a previously cached query plan.
以前にキャッシュされたクエリプランの最後の既知の実際の実行プランに相当するものを返します。
sys.dm_exec_requests
Returns information about each request that is executing in SQL Server.
SQL Serverで実行されている各要求に関する情報を返します。
sys.dm_exec_session_wait_stats
Returns information about all the waits encountered by threads that executed for each session. You can use this view to diagnose performance issues with the SQL Server session and also with specific queries and batches. This view returns session the same information that is aggregated for sys.dm_os_wait_stats (Transact-SQL) but provides the session_id number as well.
各セッションで実行されたスレッドが遭遇したすべての待機に関する情報を返します。 このビューを使用して、SQL Serverセッションおよび特定のクエリとバッチのパフォーマンスの問題を診断できます。 このビューは、sys.dm_os_wait_stats(Transact-SQL)について集約されたものと同じ情報をセッションに返しますが、session_id番号も提供します。
sys.dm_exec_text_query_plan
Returns the Showplan in text format for a Transact-SQL batch or for a specific statement within the batch. The query plan specified by the plan handle can either be cached or currently executing. This table-valued function is similar to sys.dm_exec_query_plan (Transact-SQL), but has the following differences:
  • The output of the query plan is returned in text format.
  • The output of the query plan is not limited in size.
  • Individual statements within the batch can be specified.

Transact-SQLバッチまたはバッチ内の特定のステートメントのショープランをテキスト形式で返します。 プランハンドルで指定されたクエリプランは、キャッシュするか、現在実行中のいずれかです。 このテーブル値関数はsys.dm_exec_query_plan(Transact-SQL)に似ていますが、次の違いがあります。
  • クエリプランの出力はテキスト形式で返されます。
  • クエリプランの出力のサイズに制限はありません。
  • バッチ内の個々のステートメントを指定できます。
sys.dm_exec_trigger_stats
Returns aggregate performance statistics for cached triggers. The view contains one row per trigger, and the lifetime of the row is as long as the trigger remains cached. When a trigger is removed from the cache, the corresponding row is eliminated from this view. At that time, a Performance Statistics SQL trace event is raised similar to sys.dm_exec_query_stats.
キャッシュされたトリガーの集計パフォーマンス統計を返します。 ビューにはトリガーごとに1つの行が含まれ、行の有効期間はトリガーがキャッシュされている限りです。 トリガーがキャッシュから削除されると、対応する行がこのビューから削除されます。 その時点で、ys.dm_exec_query_statsと同様のパフォーマンス統計SQLトレースイベントが発生します。
sys.dm_exec_valid_use_hints
Returns USE HINT supported hint names. It lists one hint name per row.Use this DMV to see the list of all supported hints under the USE HINT notation.
USE HINTがサポートするヒント名を返します。 行ごとに1つのヒント名がリストされます。このDMVを使用して、USE HINT表記でサポートされているすべてのヒントのリストを表示します。
sys.dm_exec_xml_handles
Returns information about active handles that have been opened by sp_xml_preparedocument.
sp_xml_preparedocumentによって開かれたアクティブなハンドルに関する情報を返します。
sys.dm_external_script_execution_stats
Returns one row for each type of external script request. The external script requests are grouped by the supported external script language. One row is generated for each registered external script functions. Arbitrary external script functions are not recorded unless sent by a parent process, such as
外部スクリプトリクエストのタイプごとに1行を返します。 外部スクリプトリクエストは、サポートされている外部スクリプト言語ごとにグループ化されます。 登録済みの外部スクリプト関数ごとに1行が生成されます。 次のような親プロセスから送信されない限り、任意の外部スクリプト関数は記録されません。
sys.dm_external_script_requests
Returns a row for each active worker account that is running an external script.
外部スクリプトを実行しているアクティブなワーカーアカウントごとに行を返します。
sys.dm_exec_sql_text
Returns the text of the SQL batch that is identified by the specified sql_handle. This table-valued function replaces the system function fn_get_sql.
指定されたsql_handleによって識別されるSQLバッチのテキストを返します。 このテーブル値関数は、システム関数fn_get_sqlを置き換えます。
 

MCSA SQL Server 2016 /70-762/CASCADE, Implicit transaction, Explicit taransaction

2019-12-27 05:16:51 | プログラム 勉強

インフルダウンしてたら、Cascade、やImplicit transaction、Explicit transactionがわからなくなってました。

【Cascade】

FOREIGN KEY (foreign_key_columns)
    REFERENCES parent_table(parent_key_columns)
    ON UPDATE action
    ON DELETE action;
 
--ON DELETE action
  • ON DELETE NO ACTION: SQL Server raises an error and rolls back the delete action on the row in the parent table.(SQL Serverはエラーを発生させ、親テーブルの行の削除アクションをロールバックします。)
  • ON DELETE CASCADE: SQL Server deletes the rows in the child table that is corresponding to the row deleted from the parent table.(SQL Serverは、親テーブルから削除された行に対応する子テーブルの行を削除します。)
  • ON DELETE SET NULL: SQL Server sets the rows in the child table to NULL if the corresponding rows in the parent table are deleted. To execute this action, the foreign key columns must be nullable.(親テーブルの対応する行が削除されると、SQL Serverは子テーブルの行をNULLに設定します。 このアクションを実行するには、外部キー列がNULL可能である必要があります。)
  • ON DELETE SET DEFAULT SQL Server sets the rows in the child table to their default values if the corresponding rows in the parent table are deleted. To execute this action, the foreign key columns must have default definitions. Note that a nullable column has a default value of NULL if no default value specified.(親テーブルの対応する行が削除された場合、SQLServerは子テーブルの行をデフォルト値に設定します。 このアクションを実行するには、外部キー列にデフォルトの定義が必要です。 デフォルト値が指定されていない場合、ヌル可能列のデフォルト値はNULLであることに注意してください。)

 --ON UPDATE action

  • ON UPDATE NO ACTION: SQL Server raises an error and rolls back the update action on the row in the parent table.(SQL Serverはエラーを発生させ、親テーブルの行の更新アクションをロールバックします。)
  • ON UPDATE CASCADE: SQL Server updates the corresponding rows in the child table when the rows in the parent table are updated.(SQL Serverは、親テーブルの行が更新されると、子テーブルの対応する行を更新します。)
  • ON UPDATE SET NULL: SQL Server sets the rows in the child table to NULL when the corresponding row in the parent table is updated. Note that the foreign key columns must be nullable for this action to execute.(SQL Serverは、親テーブルの対応する行が更新されると、子テーブルの行をNULLに設定します。 このアクションを実行するには、外部キー列がNULL可能でなければならないことに注意してください。)
  • ON UPDATE SET DEFAULT: SQL Server sets the default values for the rows in the child table that have the corresponding rows in the parent table updated.(SQL Serverは、更新された親テーブルの対応する行を持つ子テーブルの行にデフォルト値を設定します。)

 

【70-782からの問題】

*毎度グーグル翻訳ですんません。

さて、こんな問題がありました。病み上がりですっかりぱっぱらぱーになってました。

You are developing a new application that uses a stored procedure. The stored procedure inserts thousands of records as a single batch into the Employees table.
Users report that the application response time has worsened since the stored procedure was updated. You examine disk-related performance counters for the
Microsoft SQL Server instance and observe several high values that include a disk performance issue. You examine wait statistics and observe an unusually high
WRITELOG value.

ストアドプロシージャを使用する新しいアプリケーションを開発しています。 ストアドプロシージャは、何千ものレコードを単一のバッチとしてEmployeesテーブルに挿入します。ユーザーは、ストアドプロシージャが更新されてからアプリケーションの応答時間が悪化したと報告しています。 ディスク関連のパフォーマンスカウンターを調べます。Microsoft SQL Serverインスタンス。ディスクパフォーマンスの問題を含むいくつかの高い値を観察します。 待機統計を調べて、異常に高いWRITELOG値。
You need to improve the application response time.
アプリケーションの応答時間を改善する必要があります。

Solution: You update the application to use implicit transactions when connecting to the database.

解決策:データベースに接続するときに暗黙的なトランザクションを使用するようにアプリケーションを更新します。

Does the solution meet the goal?ソリューションは目標を達成していますか?

 

<答え>いいえ

 

では、↓を見てみましょう。


【暗黙的なトランザクション - Implicit transaction】

 In Implicit transaction mode, the instance of the SQL Server Database Engine automatically starts a new transaction after the current transaction is committed or rolled back for each DML statement. We do not need to define the start of a transaction; each statement level transaction will be committed or rolled back automatically. Implicit transaction can be turned on or off per batch basis. We can use the “SET IMPLICIT_TRANSACTIONS ON/OFF” statement to turn implicit transaction mode off. We can use the “COMMIT TRANSACTION” or “ROLLBACK TRANSACTION” statements to end each transaction.

暗黙的トランザクションモードでは、SQL Serverデータベースエンジンのインスタンスは、DMLステートメントごとに現在のトランザクションがコミットまたはロールバックされた後、自動的に新しいトランザクションを開始します。 トランザクションの開始を定義する必要はありません。 各ステートメントレベルのトランザクションは自動的にコミットまたはロールバックされます。 暗黙的なトランザクションは、バッチごとにオンまたはオフにできます。 「SET IMPLICIT_TRANSACTIONS ON / OFF」ステートメントを使用して、暗黙的なトランザクションモードをオフにすることができます。 「COMMIT TRANSACTION」または「ROLLBACK TRANSACTION」ステートメントを使用して、各トランザクションを終了できます。

【明示的なトランザクション - Explicit transaction】

An explicit transaction is one in which we explicitly define both the starting and ending of the transaction. To start an explicit transaction, we can use “BEGIN TRANSACTION” and then complete the transaction by using “COMMIT TRANSACTION” or “ROLLBACK TRANSACTION”.明示的なトランザクションとは、トランザクションの開始と終了の両方を明示的に定義するトランザクションです。 明示的なトランザクションを開始するには、「BEGIN TRANSACTION」を使用してから、「COMMIT TRANSACTION」または「ROLLBACK TRANSACTION」を使用してトランザクションを完了します。

【暗黙的・明示的の違い】

インジケータ

暗黙的なトランザクション

明示的なトランザクション

スコープ

ステートメントレベル

バッチレベル

ログ生成

トランザクションの連続チェーン

1つのトランザクションログエントリ

Log I/O

ステートメントごとに1つのI / Oを取得します

バッチ全体に1つのI / Oが必要です

WRITELOG Waittype

持続期間

N / Aまたは実ディスクの問題がない限り

応答/期間

いくつかのI / Oアクティビティのために長く

高速で少ないI / Oアクティビティ

T-Log Restore

長い、やり直し/元に戻すフェーズ

短いREDO / UNDOフェーズ

T-Logへの影響

非常に高い

少なくて取るに足らない

書き込み時間

長くて遅い

短くて速い

The application which is utilizing the Implicit Transaction mechanism actually makes the I/O system busy and degrades application response time dramatically. As a result, various disk related performance counters show significantly high values and we start believing that the disk is the bottleneck.

Implicit Transactionメカニズムを利用しているアプリケーションは、実際にI / Oシステムをビジーにし、アプリケーションの応答時間を劇的に低下させます。 その結果、さまざまなディスク関連のパフォーマンスカウンターが非常に高い値を示し、ディスクがボトルネックであると考え始めています。

 

 

。。。今思ったけど、こんなに詳しくノートとる必要なかったかもです。あぁ、はやく鼻と咳をとめたい。。。くらくらする。。。