JP2005018430A - Database managing system and query optimizing method - Google Patents

Database managing system and query optimizing method Download PDF

Info

Publication number
JP2005018430A
JP2005018430A JP2003182663A JP2003182663A JP2005018430A JP 2005018430 A JP2005018430 A JP 2005018430A JP 2003182663 A JP2003182663 A JP 2003182663A JP 2003182663 A JP2003182663 A JP 2003182663A JP 2005018430 A JP2005018430 A JP 2005018430A
Authority
JP
Japan
Prior art keywords
execution
execution plan
plan
query
inquiry
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2003182663A
Other languages
Japanese (ja)
Inventor
Kimitaka Uyama
公隆 宇山
Kinya Fujitsuka
勤也 藤塚
Keita Tanikoshi
桂太 谷越
Kimihisa Kondo
公久 近藤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
NTT Data Group Corp
Original Assignee
NTT Data Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by NTT Data Corp filed Critical NTT Data Corp
Priority to JP2003182663A priority Critical patent/JP2005018430A/en
Publication of JP2005018430A publication Critical patent/JP2005018430A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a database managing system and a query optimizing method to perform the much more accurate optimization of a query. <P>SOLUTION: A control part 11 generates a candidate execution plan regarding a predetermined query, executes all of the generated execution plans, acquires the actual costs of each execution plan and selects the execution plan of the minimum costs, and registers it in an optimal execution plan file 122 with the query. The control part 11 receives a query inputted by a user and judges whether or not the query has been registered in the optimal execution plan file 122. When the query has been registered, the control part reads the execution plan registered with the query from the optimal execution plan file 122 and executes it and outputs an execution result. When the query has not been registered in the optimal execution plan file 122, the control part performs general optimization processing and selects and executes an execution plan and outputs the execution result. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

【0001】
【発明の属する技術分野】
この発明は、データベースについて入力された問い合わせについて最適な実行プランを選択するためのデータベース管理システム(DBMS)及び問い合わせ最適化方法に関する。
【0002】
【従来の技術】
従来、一般的なDBMSでは、問い合わせ(質問、クエリ)が入力されると、問い合わせについて、効率の良い、問い合わせを実行するための手順(実行プラン)を選択する最適化処理が行われる。この問い合わせの最適化処理はデータベース処理においては極めて重要であり、例えば、最適な実行プランであれば数秒以内で処理が終わるような問い合わせであっても、実行プランの選択ミスにより、処理に数十分かかってしまうということもあり得る。
【0003】
例えば、問い合わせと意味的に等価な問い合わせを用意して、問い合わせに対する実行プランの選択幅を広げることにより、問い合わせの最適化を図るシステムもある(特許文献1参照)。
【0004】
【特許文献1】
特開平5−334368号公報(第3頁、第1図)
【0005】
【発明が解決しようとする課題】
一般的に、実行プランの最適化処理では、複数の候補の実行プランについて、統計情報(表の大きさ、属性値の分布等)等を用いて、それぞれのコストの見積もり値を算出し、そのコストの見積もり値が最小のプランを選択する。
しかし、例えば、データがディスク中でフラグメンテーションを起こしている場合等には、上記のようなコストの見積もり値を算出する方法では、実際に最適な実行プランを選択することは困難であった。
【0006】
この発明は、上記実状に鑑みてなされたものであり、より確実に問い合わせの最適化を行うことができるデータベース管理システム及び問い合わせ最適化方法を提供することを目的とする。
また、データベース運用時のパフォーマンスを向上させることができるデータベース管理システム及び問い合わせ最適化方法を提供することを他の目的とする。
【0007】
【課題を解決するための手段】
上記目的を達成するため、この発明の第1の観点に係るデータベース管理システムは、
所定の問い合わせについて、候補となる実行プランを生成し、生成された全ての実行プランを実行し、各実行プランの実際のコストを取得するコスト取得手段と、
前記コスト取得手段により取得された全ての実行プランのコストの中から最小のコストの実行プランを選択する選択手段と、
前記選択手段により選択された実行プランと前記問い合わせを関連付けて最適実行プランファイルに登録する登録手段と、
ユーザにより入力された問い合わせについて、前記最適実行プランファイルを参照してデータベースの検索を行う検索実行手段と、
を備えることを特徴とする。
【0008】
このような構成によれば、問い合わせの候補として生成される全ての実行プランについて実際のコストを求め、現実に最小のコストとなる実行プランを最適実行プランとして選択することにより、実際のシステムのハードウェア性能や実際のデータベースの状態等に基づいて、確実に問い合わせの最適化を行うことができる。また、このようにして最適化された問い合わせの実行プランをデータベースの検索に用いることにより、データベース運用時のパフォーマンスが向上する。
【0009】
前記検索実行手段は、
ユーザが入力した問い合わせを受け付ける手段と、
前記問い合わせが前記最適実行プランファイルに登録されているか否かを判別する手段と、
前記問い合わせが前記最適実行プランファイルに登録されていると判別された場合、該問い合わせに関連付けて登録されている実行プランを前記最適実行プランファイルから読み出して実行する第1のプラン実行手段と、
前記第1のプラン実行手段による実行結果を出力する手段と、
前記問い合わせが前記最適実行プランファイルに登録されていないと判別された場合、該問い合わせについて一般的な最適化処理を行って実行プランを選択し、該選択した実行プランを実行する第2のプラン実行手段と、
前記第2のプラン実行手段による実行結果を出力する手段と、
を備えてもよい。
これにより、実際のコストに基づいて選択された実行プランを用いてデータベース検索を行うため、データベース運用時のパフォーマンスが向上する。
【0010】
前記コスト取得手段は、一定期間毎に、所定の問い合わせについて実行プランの実際のコストを取得する処理を行ってもよく、
前記登録手段は、前記選択手段により選択された実行プランの問い合わせが既に登録されている場合には、登録内容を前記選択された実行プランで更新するようにしてもよい。
【0011】
また、この発明の第2の観点に係る方法は、
データベース管理システムにおける問い合わせ最適化方法であって、
所定の問い合わせについて、候補となる実行プランを生成し、生成された全ての実行プランを実行し、各実行プランの実際のコストを取得するコスト取得ステップと
前記コスト取得ステップにより取得された全ての実行プランのコストの中から最小のコストの実行プランを選択する選択ステップと、
前記選択ステップにより選択した実行プランと前記問い合わせを関連付けて最適実行プランファイルに登録する登録ステップと、
ユーザにより入力された問い合わせについて、前記最適実行プランファイルを参照してデータベースの検索を行う検索実行ステップと、
を備えることを特徴とする。
【0012】
このような構成によれば、問い合わせの候補として生成される全ての実行プランについて実際のコストを求め、現実に最小のコストとなる実行プランを最適実行プランとして選択することにより、実際のシステムのハードウェア性能や実際のデータベースの状態等に基づいて、より確実に問い合わせの最適化を行うことができる。また、このようにして最適化された問い合わせの実行プランをデータベースの検索に用いることにより、データベース運用時のパフォーマンスが向上する。
【0013】
前記検索実行ステップは、
ユーザが入力した問い合わせを受け付けるステップと、
前記問い合わせが前記最適実行プランファイルに登録されているか否かを判別するステップと、
前記問い合わせが前記最適実行プランファイルに登録されていると判別された場合、該問い合わせに関連付けて登録されている実行プランを前記最適実行プランファイルから読み出して実行する第1のプラン実行ステップと、
前記第1のプラン実行ステップによる実行結果を出力するステップと、
前記問い合わせが前記最適実行プランファイルに登録されていないと判別された場合、該問い合わせについて一般的な最適化処理を行って実行プランを選択し、該選択した実行プランを実行する第2のプラン実行ステップと、
前記第2のプラン実行ステップによる実行結果を出力するステップと、
を備えてもよい。
これにより、実際のコストに基づいて選択された実行プランを用いてデータベース検索を行うため、データベース運用時のパフォーマンスが向上する。
【0014】
前記コスト取得ステップは、一定期間毎に、所定の問い合わせについて実行プランの実際のコストを取得する処理を行ってもよく、
前記登録ステップは、前記選択ステップにより選択された実行プランの問い合わせが既に登録されている場合には、登録内容を前記選択された実行プランで更新するようにしてもよい。
【0015】
【発明の実施の形態】
以下、本発明の実施の形態に係るデータベース管理システムを図面を参照して説明する。
【0016】
この発明の実施形態に係るデータベース管理システムの機能構成図を図1に示す。このデータベース管理システム1は、例えば、制御部11、記憶部12、通信制御部13等を備えるコンピュータ等から構成される。
制御部11は、CPU(Central Processing Unit)等から構成され、記憶部12に記憶される動作プログラム等を読み出して実行することにより、管理制御部111、構文解析部112、最適化処理部113、プラン実行部114等を論理的に実現する。
【0017】
管理制御部111は、問い合わせ実行処理、問い合わせ実行処理のための準備処理等の実行を制御する。
例えば、準備処理では、管理制御部111は、構文解析部112、最適化処理部113、プラン実行部114を制御して、予め用意された準備処理用の問い合わせ(クエリ)について、構文解析処理を行った後、候補となる実行プランを生成・実行し、全候補の中から実際のコスト(例えば、実行時間等)が最もかからないプランを選択し、それを対応する問い合わせと関連付けて記憶部12の最適実行プランファイル122に記憶する。なお、準備処理の実行タイミングは任意に設定可能であり、例えば、図示せぬタイマを用いて所定時間毎に実行するようにしてもよい。
【0018】
また、問い合わせ実行処理では、管理制御部111は、構文解析部112、最適化処理部113、プラン実行部114を制御して、他のコンピュータから受け付けた、ユーザにより入力された問い合わせ(クエリ)について、構文解析処理を行った後、問い合わせが最適実行プランファイル122に登録されているか否かを判別し、登録されている場合には、その問い合わせに関連付けて登録されている実行プランを取り出し、それに従ってデータベース121の検索を行う。また、問い合わせが登録されていない場合には、一般的な統計情報等に基づく最適化処理を行って実行プランを選択し、選択した実行プランに従ってデータベース121の検索を行う。そして、データベース121の検索結果を検索要求元のコンピュータに返信する。なお、問い合わせ実行処理の実行タイミングは、例えば、ネットワークを介して他のコンピュータから問い合わせを含む検索要求を受信したとき等である。
【0019】
構文解析部112は、パーサ機能等を有し、管理制御部111からの指示に従って、入力された問い合わせについて構文解析チェックを行う。
【0020】
最適化処理部113は、オプティマイザ機能等を有し、管理制御部111からの指示に従って、構文解析部112より構文解析チェックがなされた問い合わせについて最適な実行プランを決定する。
具体的には、実際のコストに基づいて最適な実行プランを選択することを管理制御部111から指示された場合、問い合わせについて候補となる実行プランを生成し、生成した各実行プランをプラン実行部114に渡して実行させ、実際のコスト値を計測して、全ての実行プランについて実際のコストを取得する。例えば、コストが実行プランの実行時間の場合には、実行プランの実行開始から完了までの時間を計時する。そして、最もコストの小さいものを最適な実行プランとして決定し、決定した最適実行プランを対応する問い合わせとともに最適実行プランファイル122に登録する。最適実行プランファイル122の登録データ(問い合わせ及び最適実行プラン)の一例を図2に示す。
【0021】
また、一般的な最適化処理を管理制御部111から指示された場合、最適化処理部113は、例えば、候補となる実行プランを生成し、各実行プランについて、統計情報(表の大きさ、属性値の分布等)等に基づいて、コストの見積もり値を算出し、最小のコスト値の実行プランを選択するような、一般的な最適化処理を実行し、選択した実行プランをプラン実行部114に渡す。
【0022】
プラン実行部114は、管理制御部111からの指示に従って、最適化処理部113から渡された実行プランが示す手順でデータベースの検索を行う。
【0023】
記憶部12は、ハードディスク装置等から構成され、データベース121と、最適実行プランファイル122と、を備える。また、記憶部12は、制御部11が実行する動作プログラムや、処理に必要な各種のデータを記憶する。
データベース121には、検索対象となる各種データが記憶されている。
最適実行プランファイル122には、問い合わせとそれに対応する最適実行プランが関連付けて格納されている。
【0024】
通信制御部13は、ネットワークに接続され、他のコンピュータとの間でデータ通信を行うためのものである
【0025】
次に、本実施形態のデータベース管理システム1の動作について説明する。
まず、準備処理について図3のフローチャートを参照して説明する。
管理制御部111は、例えば所定時間毎のタイミングで、準備処理を開始し、処理対象の問い合わせを記憶部12から取り出し(ステップS1)、問い合わせの構文解析チェックを構文解析部112に指示する。これに応じて、構文解析部112は、指示された問い合わせについて構文解析チェックを行う(ステップS2)。
問い合わせの構文解析チェックが終わると、管理制御部111は、最適実行プランの選出を最適化処理部113に指示する。これに応じて、最適化処理部113は、問い合わせについて候補となる実行プランを生成し(ステップS3)、生成した各実行プランを順次、プラン実行部114に渡して実行させて、実際のコストを測定する処理を全ての実行プランについて行う(ステップS4、5)。
そして、最適化処理部113は、各実行プランを実際に実行して得たコストから最適な、すなわち、コストの最も小さい実行プランを最適実行プランとして選択する(ステップS6)。そして、管理制御部111は、最適化処理部113により選択された最適実行プランを、問い合わせと関連付けて、最適実行プランファイル122に登録して(ステップS7)、本処理を終了する。なお、ステップS7において、対応する問い合わせについて既に登録されている場合には、登録されているデータを更新する。
【0026】
処理対象の問い合わせが複数有る場合には、各問い合わせについて上記準備処理を実行する。例えば、管理制御部111が記憶部12に設定されている複数の問い合わせについて上記準備処理を順次実行するようにしてもよい。また、処理対象の問い合わせは、予め管理者等により図示せぬ入力部から入力され、設定されるようにしてもよく、また、管理制御部111が過去の検索ログ等を参照して、所定の基準により(例えば実行回数の多い等)問い合わせを選出し、設定するようにしてもよい。
【0027】
次に、上記準備処理により得られた最適実行プランを用いて、ユーザにより入力された問い合わせを実行する問い合わせ実行処理について図4のフローチャートを参照して説明する。
管理制御部111は、例えば、他のコンピュータから問い合わせを含む検索要求をネットワークを介して受信すると(ステップS11)、受信した問い合わせについて構文解析チェックを構文解析部112に指示する。これに応じて、構文解析部112は、指示された問い合わせについて構文解析チェックを行う(ステップS12)。
問い合わせの構文解析チェックが終わると、管理制御部111は、問い合わせが準備処理によって事前に最適化されているか、すなわち、問い合わせが最適実行プランファイル122に登録されているか否かを判別する(ステップS13)。
問い合わせが最適実行プランファイル122に登録されていると判別した場合(ステップS13:YES)、管理制御部111は、その問い合わせに対応する最適実行プランを最適実行プランファイル122から読み出して、プラン実行部114に渡して実行させる(ステップS15)。
【0028】
また、問い合わせが最適実行プランファイル122に登録されていないと判別した場合(ステップS13:NO)、管理制御部111は、一般的な最適化処理の実行を最適化処理部113に指示する。これに応じて、最適化処理部113は、実行プランの候補を生成し、各実行プランについてコストの見積もり値を算出し、コストが最小の実行プランを選択し、プラン実行部114に渡して実行させる(ステップS14、S15)。
そして、管理制御部111は、ステップS15におけるプラン実行部114による検索処理の実行結果を検索要求元のコンピュータにネットワークを介して送信する(ステップS16)。
【0029】
以上説明したように、本発明によれば、問い合わせの候補として生成される全ての実行プランについて実際のコストを求め、現実に最小のコストとなる実行プランを最適実行プランとして選択することにより、実際のシステムのハードウェア性能や実際のデータベースの状態等に基づいて、確実に問い合わせの最適化を行うことができる。これにより、データベース運用時のパフォーマンスが向上する。
【0030】
なお、上記実施例では、問い合わせ実行処理において、問い合わせが最適実行プランファイル122に登録されていない場合に、一般的な最適化処理を行うようにしているが、これに限定されず、例えば、準備処理のように、生成された全ての実行プランを実行し、最小のコストの実行プランを選択してもよい。さらに、選択した実行プランを問い合わせとともに、最適実行プランファイル122に登録するようにしてもよい。
【0031】
また、上記のシステム構成は一例であり、例えば、データベース121は本システムとネットワークにより接続された他のコンピュータが有するようにしてもよい。
また、本システムの機能を複数台のコンピュータにより実現してもよい。例えば、準備処理を行う第1のコンピュータと、問い合わせ実行処理を行う第2のコンピュータと、を備えても良く、データベース121及び最適実行プランファイルを、第1のコンピュータ、第2のコンピュータ、第1と第2のコンピュータとネットワークで接続された他コンピュータ、のいずれかが有する構成としてもよい。この場合、第1のコンピュータは、上記データベース管理システム1が有する機能のうち、準備処理を行うための処理プログラム及び必要なデータを記憶部に記憶し、制御部が記憶部から処理プログラムを読み出して実行することにより、準備処理を実行するための管理制御部、構文解析部、最適化処理部、プラン実行部を実現する。また、第2のコンピュータは、上記データベース管理システム1が有する機能のうち、問い合わせ実行処理を行うための処理プログラム及び必要なデータを記憶部に記憶し、制御部が記憶部から処理プログラムを読み出して実行することにより、準備処理を実行するための管理制御部、構文解析部、最適化処理部、プラン実行部を実現する。
【0032】
また、上記説明では、問い合わせはネットワークを介して他のコンピュータから受信しているが、これに限定されず、例えば、本システムが備える図示せぬ入力部からユーザが入力し、入力された問い合わせについて上記の各種処理を行うようにしてもよい。
【0033】
なお、この発明のシステムは、専用のシステムによらず、通常のコンピュータシステムを用いて実現可能である。例えば、上述の動作を実行するためのプログラムをコンピュータ読み取り可能な記録媒体(FD、CD−ROM、DVD等)に格納して配布し、該プログラムをコンピュータにインストールすることにより、上述の処理を実行するデータベース管理システム1等を構成してもよい。また、インターネット等のネットワーク上のサーバ装置が有するディスク装置に格納しておき、例えばコンピュータにダウンロード等するようにしてもよい。
また、上述の機能を、OSが分担又はOSとアプリケーションの共同により実現する場合等には、OS以外の部分のみを媒体に格納して配布してもよく、また、コンピュータにダウンロード等してもよい。
【0034】
【発明の効果】
このような構成によれば、より確実に問い合わせの最適化を行うことができる。
【図面の簡単な説明】
【図1】この発明の実施の形態に係るデータベース管理システムの構成を示す図である。
【図2】最適実行プランファイルの登録データの一例を示す図である。
【図3】準備処理を説明するためのフローチャートである。
【図4】問い合わせ実行処理を説明するためのフローチャートである。
【符号の説明】
1 データベース管理システム
11 制御部
111 管理制御部
112 構文解析部
113 最適化処理部
114 プラン実行部
12 記憶部
121 データベース
122 最適実行プランファイル
13 通信制御部
[0001]
BACKGROUND OF THE INVENTION
The present invention relates to a database management system (DBMS) and a query optimization method for selecting an optimal execution plan for a query input for a database.
[0002]
[Prior art]
Conventionally, in a general DBMS, when a query (question, query) is input, an optimization process for selecting an efficient procedure (execution plan) for executing the query is performed. This query optimization process is extremely important in database processing. For example, even an query that can be processed within a few seconds if it is an optimal execution plan, the process is tens of times due to an execution plan selection error. It can take a minute.
[0003]
For example, there is a system that optimizes a query by preparing a query that is semantically equivalent to the query and expanding the selection range of execution plans for the query (see Patent Document 1).
[0004]
[Patent Document 1]
JP-A-5-334368 (page 3, FIG. 1)
[0005]
[Problems to be solved by the invention]
In general, in the execution plan optimization process, for each candidate execution plan, statistical information (table size, attribute value distribution, etc.) is used to calculate the estimated value of each cost. Select the plan with the lowest cost estimate.
However, for example, when the data is fragmented in the disk, it is difficult to actually select the optimum execution plan by the method for calculating the estimated cost as described above.
[0006]
The present invention has been made in view of the above circumstances, and an object thereof is to provide a database management system and a query optimization method capable of performing query optimization more reliably.
Another object of the present invention is to provide a database management system and a query optimization method capable of improving performance during database operation.
[0007]
[Means for Solving the Problems]
In order to achieve the above object, a database management system according to the first aspect of the present invention provides:
For a given query, a cost acquisition unit that generates candidate execution plans, executes all the generated execution plans, and acquires the actual cost of each execution plan;
Selecting means for selecting an execution plan with the minimum cost from the costs of all execution plans acquired by the cost acquisition means;
Registration means for associating the inquiry with the execution plan selected by the selection means and registering it in the optimum execution plan file;
Search execution means for searching the database with reference to the optimal execution plan file for the query input by the user;
It is characterized by providing.
[0008]
According to such a configuration, the actual cost is obtained for all execution plans generated as query candidates, and the actual execution system hardware is selected by selecting the execution plan having the lowest actual cost as the optimum execution plan. Inquiries can be reliably optimized based on hardware performance, actual database status, and the like. Further, by using the query execution plan optimized in this way for database search, the performance during database operation is improved.
[0009]
The search execution means includes
Means for accepting inquiries entered by the user;
Means for determining whether or not the inquiry is registered in the optimum execution plan file;
First plan execution means for reading out and executing an execution plan registered in association with the inquiry from the optimum execution plan file when it is determined that the inquiry is registered in the optimum execution plan file;
Means for outputting an execution result by the first plan execution means;
When it is determined that the query is not registered in the optimum execution plan file, a second optimization is executed to perform a general optimization process on the query, select an execution plan, and execute the selected execution plan Means,
Means for outputting an execution result by the second plan execution means;
May be provided.
As a result, the database search is performed using the execution plan selected based on the actual cost, so that the performance during database operation is improved.
[0010]
The cost acquisition means may perform a process of acquiring an actual cost of an execution plan for a predetermined inquiry every predetermined period,
The registration unit may update the registered content with the selected execution plan when an inquiry about the execution plan selected by the selection unit has already been registered.
[0011]
A method according to the second aspect of the present invention is as follows.
A query optimization method in a database management system,
Generate a candidate execution plan for a given query, execute all the generated execution plans, and acquire the actual cost of each execution plan, and all executions acquired by the cost acquisition step A selection step of selecting an execution plan with the lowest cost from the costs of the plan;
A registration step of associating the execution plan selected in the selection step with the inquiry and registering it in an optimal execution plan file;
A search execution step of searching a database with reference to the optimal execution plan file for the query input by the user;
It is characterized by providing.
[0012]
According to such a configuration, the actual cost is obtained for all execution plans generated as query candidates, and the actual execution system hardware is selected by selecting the execution plan having the lowest actual cost as the optimum execution plan. Inquiries can be more reliably optimized based on hardware performance and actual database status. Further, by using the query execution plan optimized in this way for database search, the performance during database operation is improved.
[0013]
The search execution step includes:
Receiving a query entered by the user;
Determining whether the inquiry is registered in the optimal execution plan file; and
When it is determined that the inquiry is registered in the optimum execution plan file, a first plan execution step of reading and executing the execution plan registered in association with the inquiry from the optimum execution plan file;
Outputting an execution result of the first plan execution step;
When it is determined that the query is not registered in the optimum execution plan file, a second optimization is executed to perform a general optimization process on the query, select an execution plan, and execute the selected execution plan Steps,
Outputting an execution result of the second plan execution step;
May be provided.
As a result, the database search is performed using the execution plan selected based on the actual cost, so that the performance during database operation is improved.
[0014]
The cost acquisition step may perform a process of acquiring an actual cost of an execution plan for a predetermined inquiry every predetermined period,
In the registration step, when an inquiry about the execution plan selected in the selection step has already been registered, the registration content may be updated with the selected execution plan.
[0015]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, a database management system according to an embodiment of the present invention will be described with reference to the drawings.
[0016]
FIG. 1 shows a functional configuration diagram of the database management system according to the embodiment of the present invention. The database management system 1 includes, for example, a computer including a control unit 11, a storage unit 12, a communication control unit 13, and the like.
The control unit 11 includes a CPU (Central Processing Unit) and the like, and reads and executes an operation program stored in the storage unit 12 to thereby execute a management control unit 111, a syntax analysis unit 112, an optimization processing unit 113, The plan execution unit 114 and the like are logically realized.
[0017]
The management control unit 111 controls execution of inquiry execution processing, preparation processing for inquiry execution processing, and the like.
For example, in the preparation process, the management control unit 111 controls the syntax analysis unit 112, the optimization processing unit 113, and the plan execution unit 114 to perform a syntax analysis process on a prepared process inquiry (query). After the execution, a candidate execution plan is generated and executed, a plan with the lowest actual cost (for example, execution time, etc.) is selected from all candidates, and is associated with the corresponding inquiry in the storage unit 12 The optimal execution plan file 122 is stored. The execution timing of the preparation process can be arbitrarily set. For example, the preparation process may be executed at predetermined intervals using a timer (not shown).
[0018]
In the query execution process, the management control unit 111 controls the syntax analysis unit 112, the optimization processing unit 113, and the plan execution unit 114, and receives a query (query) input by the user that is received from another computer. After performing the parsing process, it is determined whether or not the query is registered in the optimum execution plan file 122. If registered, the execution plan registered in association with the query is taken out, and The database 121 is searched according to the above. When no inquiry is registered, an optimization plan based on general statistical information or the like is performed to select an execution plan, and the database 121 is searched according to the selected execution plan. Then, the search result of the database 121 is returned to the search request source computer. The execution timing of the inquiry execution process is, for example, when a search request including an inquiry is received from another computer via the network.
[0019]
The syntax analysis unit 112 has a parser function and the like, and performs a syntax analysis check on the input query in accordance with an instruction from the management control unit 111.
[0020]
The optimization processing unit 113 has an optimizer function and the like, and determines an optimal execution plan for a query that has undergone a syntax analysis check from the syntax analysis unit 112 in accordance with an instruction from the management control unit 111.
Specifically, when the management control unit 111 instructs to select an optimal execution plan based on the actual cost, a candidate execution plan is generated for the inquiry, and each generated execution plan is displayed as a plan execution unit. 114, the actual cost value is measured, and the actual cost is obtained for all execution plans. For example, when the cost is the execution time of the execution plan, the time from the execution start to the completion of the execution plan is measured. Then, the one with the lowest cost is determined as the optimal execution plan, and the determined optimal execution plan is registered in the optimal execution plan file 122 together with the corresponding inquiry. An example of registration data (inquiry and optimum execution plan) of the optimum execution plan file 122 is shown in FIG.
[0021]
When general management processing is instructed by the management control unit 111, the optimization processing unit 113 generates, for example, candidate execution plans, and statistical information (table size, Based on the distribution of attribute values, etc.), an estimated cost value is calculated, a general optimization process such as selecting an execution plan with the minimum cost value is executed, and the selected execution plan is a plan execution unit. 114.
[0022]
The plan execution unit 114 searches the database according to the procedure indicated by the execution plan passed from the optimization processing unit 113 according to the instruction from the management control unit 111.
[0023]
The storage unit 12 includes a hard disk device or the like, and includes a database 121 and an optimal execution plan file 122. The storage unit 12 stores an operation program executed by the control unit 11 and various data necessary for processing.
The database 121 stores various data to be searched.
The optimum execution plan file 122 stores the inquiry and the optimum execution plan corresponding to the inquiry.
[0024]
The communication control unit 13 is connected to a network and performs data communication with other computers.
Next, the operation of the database management system 1 of this embodiment will be described.
First, the preparation process will be described with reference to the flowchart of FIG.
For example, the management control unit 111 starts a preparation process at a predetermined time interval, retrieves a query to be processed from the storage unit 12 (step S1), and instructs the syntax analysis unit 112 to perform a syntax analysis check of the query. In response to this, the syntax analysis unit 112 performs a syntax analysis check on the inquired query (step S2).
When the query parsing check is completed, the management control unit 111 instructs the optimization processing unit 113 to select an optimal execution plan. In response to this, the optimization processing unit 113 generates a candidate execution plan for the inquiry (step S3), and sequentially passes the generated execution plans to the plan execution unit 114 to execute the actual cost. The measurement process is performed for all execution plans (steps S4 and S5).
Then, the optimization processing unit 113 selects, as the optimal execution plan, the optimal execution plan from the costs obtained by actually executing each execution plan, that is, the lowest cost (step S6). Then, the management control unit 111 registers the optimum execution plan selected by the optimization processing unit 113 in the optimum execution plan file 122 in association with the inquiry (step S7), and ends this process. In step S7, if the corresponding inquiry has already been registered, the registered data is updated.
[0026]
When there are a plurality of queries to be processed, the above preparation process is executed for each query. For example, the management control unit 111 may sequentially execute the preparation processing for a plurality of inquiries set in the storage unit 12. The inquiry about the processing target may be input and set in advance from an input unit (not shown) by an administrator or the like, and the management control unit 111 refers to a past search log or the like to determine a predetermined target. Inquiries may be selected and set according to criteria (for example, a large number of executions).
[0027]
Next, an inquiry execution process for executing an inquiry input by the user using the optimum execution plan obtained by the above preparation process will be described with reference to the flowchart of FIG.
For example, when receiving a search request including a query from another computer via the network (step S11), the management control unit 111 instructs the syntax analysis unit 112 to perform a syntax analysis check on the received query. In response to this, the syntax analysis unit 112 performs a syntax analysis check on the inquired instruction (step S12).
When the query parsing check is completed, the management control unit 111 determines whether the query has been optimized in advance by the preparation process, that is, whether the query is registered in the optimal execution plan file 122 (step S13). ).
When it is determined that the inquiry is registered in the optimum execution plan file 122 (step S13: YES), the management control unit 111 reads out the optimum execution plan corresponding to the inquiry from the optimum execution plan file 122, and executes the plan execution unit. 114 for execution (step S15).
[0028]
If it is determined that the inquiry is not registered in the optimum execution plan file 122 (step S13: NO), the management control unit 111 instructs the optimization processing unit 113 to execute general optimization processing. In response to this, the optimization processing unit 113 generates execution plan candidates, calculates an estimated cost value for each execution plan, selects an execution plan with the lowest cost, passes it to the plan execution unit 114, and executes it. (Steps S14 and S15).
Then, the management control unit 111 transmits the execution result of the search process by the plan execution unit 114 in step S15 to the search request source computer via the network (step S16).
[0029]
As described above, according to the present invention, the actual cost is obtained for all execution plans generated as query candidates, and the execution plan that actually has the minimum cost is selected as the optimal execution plan. Inquiries can be reliably optimized based on the hardware performance of the system and the actual database status. This improves performance during database operation.
[0030]
In the above embodiment, in the query execution process, when the query is not registered in the optimum execution plan file 122, the general optimization process is performed. As in the process, all generated execution plans may be executed, and the execution plan with the lowest cost may be selected. Furthermore, the selected execution plan may be registered in the optimum execution plan file 122 together with the inquiry.
[0031]
Further, the above system configuration is an example. For example, the database 121 may be included in another computer connected to the system via a network.
Further, the functions of this system may be realized by a plurality of computers. For example, a first computer that performs a preparation process and a second computer that performs an inquiry execution process may be included. The database 121 and the optimal execution plan file are stored in the first computer, the second computer, and the first computer. And a second computer connected to the second computer via a network. In this case, the first computer stores the processing program for performing the preparatory processing and necessary data among the functions of the database management system 1 in the storage unit, and the control unit reads the processing program from the storage unit. By executing, a management control unit, a syntax analysis unit, an optimization processing unit, and a plan execution unit for executing the preparation process are realized. The second computer stores, in the storage unit, a processing program and necessary data for performing the query execution process among the functions of the database management system 1, and the control unit reads the processing program from the storage unit. By executing, a management control unit, a syntax analysis unit, an optimization processing unit, and a plan execution unit for executing the preparation process are realized.
[0032]
In the above description, the inquiry is received from another computer via the network. However, the present invention is not limited to this. For example, the inquiry input by the user through an input unit (not shown) provided in the system. The above various processes may be performed.
[0033]
The system of the present invention can be realized using a normal computer system, not a dedicated system. For example, a program for executing the above operation is stored in a computer-readable recording medium (FD, CD-ROM, DVD, etc.) and distributed, and the program is installed in the computer to execute the above processing. The database management system 1 or the like may be configured. Alternatively, it may be stored in a disk device of a server device on a network such as the Internet and downloaded to a computer, for example.
In addition, when the OS realizes the above functions by sharing the OS or jointly with the OS and the application, etc., only the part other than the OS may be stored and distributed in the medium, or may be downloaded to the computer. Good.
[0034]
【The invention's effect】
According to such a configuration, the inquiry can be optimized more reliably.
[Brief description of the drawings]
FIG. 1 is a diagram showing a configuration of a database management system according to an embodiment of the present invention.
FIG. 2 is a diagram illustrating an example of registration data of an optimum execution plan file.
FIG. 3 is a flowchart for explaining preparatory processing.
FIG. 4 is a flowchart for explaining inquiry execution processing;
[Explanation of symbols]
DESCRIPTION OF SYMBOLS 1 Database management system 11 Control part 111 Management control part 112 Syntax analysis part 113 Optimization processing part 114 Plan execution part 12 Storage part 121 Database 122 Optimal execution plan file 13 Communication control part

Claims (6)

データベースに対する所定の問い合わせについて、候補となる実行プランを生成し、生成された全ての実行プランを実行し、各実行プランの実際のコストを取得するコスト取得手段と、
前記コスト取得手段により取得された全ての実行プランのコストの中から最小のコストの実行プランを選択する選択手段と、
前記選択手段により選択された実行プランと前記問い合わせを関連付けて最適実行プランファイルに登録する登録手段と、
ユーザにより入力された問い合わせについて、前記最適実行プランファイルを参照してデータベースの検索を行う検索実行手段と、
を備えることを特徴とするデータベース管理システム。
A cost acquisition unit that generates candidate execution plans for a predetermined query to the database, executes all the generated execution plans, and acquires the actual cost of each execution plan;
Selecting means for selecting an execution plan with the minimum cost from the costs of all execution plans acquired by the cost acquisition means;
Registration means for associating the inquiry with the execution plan selected by the selection means and registering it in the optimum execution plan file;
Search execution means for searching the database with reference to the optimal execution plan file for the query input by the user;
A database management system comprising:
前記検索実行手段は、
ユーザが入力した問い合わせを受け付ける手段と、
前記問い合わせが前記最適実行プランファイルに登録されているか否かを判別する手段と、
前記問い合わせが前記最適実行プランファイルに登録されていると判別された場合、該問い合わせに関連付けて登録されている実行プランを前記最適実行プランファイルから読み出して実行する第1のプラン実行手段と、
前記第1のプラン実行手段による実行結果を出力する手段と、
前記問い合わせが前記最適実行プランファイルに登録されていないと判別された場合、該問い合わせについて一般的な最適化処理を行って実行プランを選択し、該選択した実行プランを実行する第2のプラン実行手段と、
前記第2のプラン実行手段による実行結果を出力する手段と、
を備えることを特徴とする請求項1に記載のデータベース管理システム。
The search execution means includes
Means for accepting inquiries entered by the user;
Means for determining whether or not the inquiry is registered in the optimum execution plan file;
First plan execution means for reading out and executing an execution plan registered in association with the inquiry from the optimum execution plan file when it is determined that the inquiry is registered in the optimum execution plan file;
Means for outputting an execution result by the first plan execution means;
When it is determined that the query is not registered in the optimum execution plan file, a second optimization is executed to perform a general optimization process on the query, select an execution plan, and execute the selected execution plan Means,
Means for outputting an execution result by the second plan execution means;
The database management system according to claim 1, further comprising:
前記コスト取得手段は、一定期間毎に、所定の問い合わせについて実行プランの実際のコストを取得する処理を行い、
前記登録手段は、前記選択手段により選択された実行プランの問い合わせが既に登録されている場合には、登録内容を前記選択された実行プランで更新する、
ことを特徴とする請求項1又は2に記載のデータベース管理システム。
The cost acquisition means performs a process of acquiring an actual cost of an execution plan for a predetermined inquiry every predetermined period,
The registration unit updates the registered content with the selected execution plan when an inquiry about the execution plan selected by the selection unit is already registered.
The database management system according to claim 1 or 2, characterized by the above.
データベース管理システムにおける問い合わせ最適化方法であって、
所定の問い合わせについて、候補となる実行プランを生成し、生成された全ての実行プランを実行し、各実行プランの実際のコストを取得するコスト取得ステップと
前記コスト取得ステップにより取得された全ての実行プランのコストの中から最小のコストの実行プランを選択する選択ステップと、
前記選択ステップにより選択した実行プランと前記問い合わせを関連付けて最適実行プランファイルに登録する登録ステップと、
ユーザにより入力された問い合わせについて、前記最適実行プランファイルを参照してデータベースの検索を行う検索実行ステップと、
を備えることを特徴とする問い合わせ最適化方法。
A query optimization method in a database management system,
Generate a candidate execution plan for a given query, execute all the generated execution plans, and acquire the actual cost of each execution plan, and all executions acquired by the cost acquisition step A selection step of selecting an execution plan with the lowest cost from the costs of the plan;
A registration step of associating the execution plan selected in the selection step with the inquiry and registering it in an optimal execution plan file;
A search execution step of searching a database with reference to the optimal execution plan file for the query input by the user;
A query optimization method characterized by comprising:
前記検索実行ステップは、
ユーザが入力した問い合わせを受け付けるステップと、
前記問い合わせが前記最適実行プランファイルに登録されているか否かを判別するステップと、
前記問い合わせが前記最適実行プランファイルに登録されていると判別された場合、該問い合わせに関連付けて登録されている実行プランを前記最適実行プランファイルから読み出して実行する第1のプラン実行ステップと、
前記第1のプラン実行ステップによる実行結果を出力するステップと、
前記問い合わせが前記最適実行プランファイルに登録されていないと判別された場合、該問い合わせについて一般的な最適化処理を行って実行プランを選択し、該選択した実行プランを実行する第2のプラン実行ステップと、
前記第2のプラン実行ステップによる実行結果を出力するステップと、
を備えることを特徴とする請求項4に記載の問い合わせ最適化方法。
The search execution step includes:
Receiving a query entered by the user;
Determining whether the inquiry is registered in the optimal execution plan file; and
When it is determined that the inquiry is registered in the optimum execution plan file, a first plan execution step of reading and executing the execution plan registered in association with the inquiry from the optimum execution plan file;
Outputting an execution result of the first plan execution step;
When it is determined that the query is not registered in the optimum execution plan file, a second optimization is executed to perform a general optimization process on the query, select an execution plan, and execute the selected execution plan Steps,
Outputting an execution result of the second plan execution step;
The query optimization method according to claim 4, further comprising:
前記コスト取得ステップは、一定期間毎に、所定の問い合わせについて実行プランの実際のコストを取得する処理を行い、
前記登録ステップは、前記選択ステップにより選択された実行プランの問い合わせが既に登録されている場合には、登録内容を前記選択された実行プランで更新する、
ことを特徴とする請求項4又は5に記載の問い合わせ最適化方法。
The cost acquisition step performs a process of acquiring an actual cost of an execution plan for a predetermined inquiry every predetermined period,
In the registration step, when an inquiry about the execution plan selected in the selection step is already registered, the registration content is updated with the selected execution plan.
6. The inquiry optimization method according to claim 4, wherein the inquiry is optimized.
JP2003182663A 2003-06-26 2003-06-26 Database managing system and query optimizing method Pending JP2005018430A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003182663A JP2005018430A (en) 2003-06-26 2003-06-26 Database managing system and query optimizing method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003182663A JP2005018430A (en) 2003-06-26 2003-06-26 Database managing system and query optimizing method

Publications (1)

Publication Number Publication Date
JP2005018430A true JP2005018430A (en) 2005-01-20

Family

ID=34182981

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003182663A Pending JP2005018430A (en) 2003-06-26 2003-06-26 Database managing system and query optimizing method

Country Status (1)

Country Link
JP (1) JP2005018430A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008210003A (en) * 2007-02-23 2008-09-11 Masaru Kiregawa Computer system and power saving method
KR100906454B1 (en) 2009-03-18 2009-07-08 주식회사 신시웨이 Database log data management apparatus and method thereof
JP2014241042A (en) * 2013-06-11 2014-12-25 日本電信電話株式会社 Virtual db system and virtual db system information processing method
JP2018509666A (en) * 2016-02-19 2018-04-05 華為技術有限公司Huawei Technologies Co.,Ltd. Method and apparatus for determining a SQL execution plan

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008210003A (en) * 2007-02-23 2008-09-11 Masaru Kiregawa Computer system and power saving method
KR100906454B1 (en) 2009-03-18 2009-07-08 주식회사 신시웨이 Database log data management apparatus and method thereof
JP2014241042A (en) * 2013-06-11 2014-12-25 日本電信電話株式会社 Virtual db system and virtual db system information processing method
JP2018509666A (en) * 2016-02-19 2018-04-05 華為技術有限公司Huawei Technologies Co.,Ltd. Method and apparatus for determining a SQL execution plan
US10901976B2 (en) 2016-02-19 2021-01-26 Huawei Technologies Co., Ltd. Method and apparatus for determining SQL execution plan

Similar Documents

Publication Publication Date Title
US7146363B2 (en) System and method for cardinality estimation based on query execution feedback
US7860858B2 (en) Closed-loop predicate analysis
US7290131B2 (en) Guaranteeing hypertext link integrity
US7664730B2 (en) Method and system for implementing a SQL profile
US7743050B1 (en) Model generation for ranking documents based on large data sets
US20170308602A1 (en) Apparatus And Methods Of Data Synchronization
US6138111A (en) Cardinality-based join ordering
US7721288B2 (en) Organizing transmission of repository data
US7840555B2 (en) System and a method for identifying a selection of index candidates for a database
US20080195578A1 (en) Automatically determining optimization frequencies of queries with parameter markers
US7823053B2 (en) System and method for searching error messages
US20070214104A1 (en) Method and system for locking execution plan during database migration
JP5527027B2 (en) Schema definition generation device, schema definition generation method, and schema definition generation program
US6052687A (en) Relational database search system and method, and intermediate link table generating method and storage medium
CN1834965A (en) Method and system for assessing quality of search engines
US20120150827A1 (en) Data storage device with duplicate elimination function and control device for creating search index for the data storage device
EP3977308B1 (en) Learning-based query plan cache for capturing low-cost query plan
US11074296B2 (en) Query generation assist method and query generation assist apparatus
US20080005077A1 (en) Encoded version columns optimized for current version access
JP2005018430A (en) Database managing system and query optimizing method
JP2012159887A (en) Retrieval request control device, retrieval request control program and retrieval request control method
US7886217B1 (en) Identification of web sites that contain session identifiers
US8650227B2 (en) Storage medium, determination method, and apparatus
JP2001166924A (en) Device and method for managing software developed article
CN114153874A (en) Radix estimation method, device, electronic equipment and storage medium