クエリ実行計画

ウィキペディアから無料の百科事典

クエリ実行計画(くえりじっこうけいかく)とは、ユーザが発行した問い合わせに基づきデータベース管理システム (DBMS) が内部的に生成する情報であり、これによりDBMSの行うデータ処理がプログラム的に表される。[注釈 1]

DBMSはクエリ実行計画の生成にあたりクエリ最適化の処理を行い、最も効果的に処理できると判断されたクエリ実行計画を問い合わせから導き出す。

クエリ実行計画はDBMSがその機能を実現するための内部的な情報に過ぎないが、ユーザがチューニングを行うとき手がかりとなる情報を提供するために、多くのDBMSが実行計画の表示機能を提供する。

例としてApache Derbyの実行計画を以下に示す。

Statement Name:         null Statement Text:         SELECT Country FROM Countries WHERE Region = 'Central America' Parse Time: 10 Bind Time: 0 Optimize Time: 370 Generate Time: 10 Compile Time: 390 Execute Time: 0 Begin Compilation Timestamp : 2005-05-25 09:20:41.274 End Compilation Timestamp : 2005-05-25 09:20:41.664 Begin Execution Timestamp : 2005-05-25 09:20:41.674 End Execution Timestamp : 2005-05-25 09:20:41.674 Statement Execution Plan Text: Project-Restrict ResultSet (2): Number of opens = 1 Rows seen = 6 Rows filtered = 0 restriction = false projection = true         constructor time (milliseconds) = 0         open time (milliseconds) = 0         next time (milliseconds) = 0         close time (milliseconds) = 0         restriction time (milliseconds) = 0         projection time (milliseconds) = 0         optimizer estimated row count:           11.90         optimizer estimated cost:           69.35  Source result set:         Table Scan ResultSet for COUNTRIES at read committed isolation level using instantaneous share row locking chosen by the optimizer         Number of opens = 1         Rows seen = 6         Rows filtered = 0         Fetch Size = 16                 constructor time (milliseconds) = 0                 open time (milliseconds) = 10                 next time (milliseconds) = 0                 close time (milliseconds) = 0                 next time in milliseconds/row = 0          scan information:                 Bit set of columns fetched={0, 2}                 Number of columns fetched=2                 Number of pages visited=3                 Number of rows qualified=6                 Number of rows visited=114                 Scan type=heap                 start position: null            stop position: null            qualifiers: Column[0][0] Id: 2 Operator: = Ordered nulls: false Unknown return value: false Negate comparison result: false                  optimizer estimated row count:           11.90                 optimizer estimated cost:           69.35 

注釈[編集]

  1. ^ ここでプログラム的に表されるとは、プログラムが実行計画に単純に従うことにより、実行計画が表すデータ処理を行えることを意味する。