JP6898215B2 - Database management device, database management method and database management program - Google Patents

Database management device, database management method and database management program Download PDF

Info

Publication number
JP6898215B2
JP6898215B2 JP2017238546A JP2017238546A JP6898215B2 JP 6898215 B2 JP6898215 B2 JP 6898215B2 JP 2017238546 A JP2017238546 A JP 2017238546A JP 2017238546 A JP2017238546 A JP 2017238546A JP 6898215 B2 JP6898215 B2 JP 6898215B2
Authority
JP
Japan
Prior art keywords
view
databases
database
subquery
unit
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.)
Active
Application number
JP2017238546A
Other languages
Japanese (ja)
Other versions
JP2019106039A (en
Inventor
茂莉 黒川
茂莉 黒川
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.)
KDDI Corp
Original Assignee
KDDI 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 KDDI Corp filed Critical KDDI Corp
Priority to JP2017238546A priority Critical patent/JP6898215B2/en
Publication of JP2019106039A publication Critical patent/JP2019106039A/en
Application granted granted Critical
Publication of JP6898215B2 publication Critical patent/JP6898215B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

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

Description

本発明は、データベース管理装置、データベース管理方法及びデータベース管理プログラムに関する。 The present invention relates to a database management device, a database management method, and a database management program.

従来、データ仮想化技術を用いることにより、複数のデータベースシステム(以下、データベースという。)を仮想的に統合したデータ統合環境を構築することが行われている。 Conventionally, by using data virtualization technology, a data integration environment in which a plurality of database systems (hereinafter referred to as databases) are virtually integrated has been constructed.

データ統合環境では、データベースに格納されているテーブルを示す情報であるスキーマ情報を物理モデルと論理モデルで表現する。物理モデルでは、テーブルの物理的な格納先を示すとともに、テーブルが格納されているデータベースに接続するための接続情報を保持する。論理モデルでは、一以上の物理モデル又は論理モデルに対応する仮想テーブルを構成する。クライアントは仮想テーブルを参照して問合せ文を実行することにより、テーブルが配置されているデータベースを意識することなく問合せ文を実行することができる。 In a data integration environment, schema information, which is information indicating a table stored in a database, is represented by a physical model and a logical model. The physical model indicates the physical storage location of the table and holds connection information for connecting to the database in which the table is stored. In the logical model, a virtual table corresponding to one or more physical models or logical models is constructed. By referring to the virtual table and executing the query statement, the client can execute the query statement without being aware of the database in which the table is located.

データ統合環境では、ユーザから受け付けた問合せ文を処理する処理装置が、問合せ文の実行時に必要となるテーブルをデータベースからネットワークを介して取得し、取得したテーブルを用いて問合せ文を実行する。したがって、データ統合環境における問合せ文の実行性能は、データ通信量に依存する。このため、データ通信量を減らすことにより、データ統合環境における問合せ文の実行性能を改善することができる。 In the data integration environment, the processing device that processes the query statement received from the user acquires the table required when executing the query statement from the database via the network, and executes the query statement using the acquired table. Therefore, the execution performance of the query statement in the data integrated environment depends on the amount of data communication. Therefore, by reducing the amount of data communication, it is possible to improve the execution performance of the query statement in the data integrated environment.

非特許文献1には、データ通信量を減らす方法として、問合せ文の実行時に、問合せ文に対応する処理を、当該問合せ文に対応するテーブルを格納するデータベース上で行う方法が開示されている。しかしながら、問合せ文が複数のデータベースのそれぞれに格納されているテーブルを参照する場合、非特許文献1に記載の方法では、データベースにおける処理が限定され、通信量を効率的に削減できないという問題がある。 Non-Patent Document 1 discloses, as a method of reducing the amount of data communication, a method of performing a process corresponding to a query statement on a database storing a table corresponding to the query statement when the query statement is executed. However, when the query statement refers to a table stored in each of a plurality of databases, the method described in Non-Patent Document 1 has a problem that the processing in the database is limited and the communication volume cannot be efficiently reduced. ..

このような問題に対して、特許文献1では、問合せ文の実行時に、複数のデータベースのそれぞれに格納されているテーブルを参照する場合、データ量が小さいテーブルを一時的に一方のデータベースに移動した後、当該データベース上で、問合せ文に対応する処理を行う方法が開示されている。 In response to such a problem, in Patent Document 1, when a table stored in each of a plurality of databases is referred to when executing a query statement, a table having a small amount of data is temporarily moved to one database. Later, a method of performing processing corresponding to the inquiry statement is disclosed on the database.

また、特許文献2では、大規模データの分散処理を管理するフレームワークであるHadoop(登録商標)とデータベースとの連携において、問合せ処理に係る中間生成物をHadoop上に生成しておき、当該中間生成物を用いることにより問合せ処理を効率化する方法が開示されている。 Further, in Patent Document 2, in cooperation between Hadoop (registered trademark), which is a framework for managing distributed processing of large-scale data, and a database, an intermediate product related to query processing is generated on Hadoop, and the intermediate product is generated. A method for streamlining query processing by using a product is disclosed.

特開2016−91356号公報Japanese Unexamined Patent Publication No. 2016-91356 特表2016−529586号公報Special Table 2016-528586

Laura M. Haas,et al. “Optimizing Queries across Diverse Data Sources”, VLDB '97 Proceedings of the 23rd International Conference on Very Large Data Bases, pp. 276-285 (1997)Laura M. Haas, et al. “Optimizing Queries across Diverse Data Sources”, VLDB '97 Proceedings of the 23rd International Conference on Very Large Data Bases, pp. 276-285 (1997)

特許文献1に記載の方法を用いることで、複数のデータベースのそれぞれに格納されているテーブルを参照する場合のデータ通信量を削減することができる。しかしながら、問合せ文が複数のデータベースのそれぞれに格納されているテーブルを参照する場合において、これらのテーブルが同程度のサイズであるとき、テーブルの移動を行うことにより、通信量が増えてしまうという問題が発生する。 By using the method described in Patent Document 1, it is possible to reduce the amount of data communication when referring to the tables stored in each of a plurality of databases. However, when the query statement refers to the tables stored in each of a plurality of databases, when these tables are of the same size, there is a problem that the amount of communication increases by moving the tables. Occurs.

また、特許文献2に記載の方法を用いることにより、中間生成物を再生成するための処理量及び通信量を削減することができる。しかしながら、特許文献2に記載の方法は、Hadoop上に生成された中間生成物を用いているため、任意の複数のデータベースシステムに拡張できないという問題がある。 Further, by using the method described in Patent Document 2, the amount of processing and the amount of communication for regenerating the intermediate product can be reduced. However, since the method described in Patent Document 2 uses an intermediate product generated on Hadoop, there is a problem that it cannot be extended to any plurality of database systems.

そこで、本発明はこれらの点に鑑みてなされたものであり、複数のデータベースを使用する環境において、問合せ文の実行性能を向上させることができるデータベース管理装置、データベース管理方法及びデータベース管理プログラムを提供することを目的とする。 Therefore, the present invention has been made in view of these points, and provides a database management device, a database management method, and a database management program capable of improving the execution performance of query statements in an environment using a plurality of databases. The purpose is to do.

本発明の第1の態様に係るデータベース管理装置は、複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとを記憶する記憶部と、複数の前記データベースの少なくともいずれかに対応する複数の問合せ文を取得する取得部と、前記論理モデル及び前記物理モデルに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定する特定部と、特定された前記副問合せに対応する物理的なビューを作成する作成部と、前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデル及び前記物理モデルを更新する更新部と、を備える。 The database management device according to the first aspect of the present invention is referred to by the user, including a physical model for managing the storage location of each of the plurality of tables included in each of the plurality of databases, and a view of the table. Acquired based on the storage unit that stores the logical model that manages the virtual table, the acquisition unit that acquires a plurality of query statements corresponding to at least one of the plurality of databases, and the logical model and the physical model. Of the subqueries commonly included in at least a part of the query statements of the plurality of query statements, a specific part that identifies the subquery that refers to the plurality of databases and the physical corresponding to the identified subquery. A creation unit for creating a view, and an update unit for updating the logical model and the physical model so that the user can refer to the created view when the view is created.

前記データベース管理装置は、前記複数のテーブルの利用状況に基づいて、複数の前記データベースのうち、現在格納されているデータベースとは異なるデータベースに移行するテーブルを移行対象テーブルとして特定し、特定された前記移行対象テーブルを移行先のデータベースに移行する移行制御部をさらに備え、前記更新部は、前記物理モデルが示す前記移行対象テーブルの格納先を前記移行先のデータベースに更新し、前記特定部は、前記移行制御部による前記移行対象テーブルの移行が完了し、前記物理モデルが示す前記移行対象テーブルの格納先が更新された後、取得された複数の前記問合せ文に基づいて、複数の前記データベースを参照する副問合せを特定してもよい。 Based on the usage status of the plurality of tables, the database management device identifies a table to be migrated to a database different from the database currently stored among the plurality of databases as a migration target table, and the identified table is specified. A migration control unit that migrates the migration target table to the migration destination database is further provided, and the update unit updates the storage destination of the migration target table indicated by the physical model to the migration destination database, and the specific unit displays the migration target table. After the migration of the migration target table by the migration control unit is completed and the storage destination of the migration target table indicated by the physical model is updated, a plurality of the databases are created based on the acquired query statements. You may specify the subquery to refer to.

前記データベース管理装置は、特定された前記副問合せの処理コストと、当該副問合せを前記ビューに置き換えた場合の当該ビューの処理コストとを算出する算出部をさらに備え、前記作成部は、算出された前記副問合せの処理コストと、当該副問合せを前記ビューに置き換えた場合の当該ビューの処理コストとに基づいて、前記ビューに置き換えることによって処理コストの低下量の期待値が大きい順に当該ビューを作成してもよい。 The database management device further includes a calculation unit for calculating the processing cost of the specified subquery and the processing cost of the view when the subquery is replaced with the view, and the creation unit is calculated. Based on the processing cost of the subquery and the processing cost of the view when the subquery is replaced with the view, the view is displayed in descending order of the expected value of the amount of reduction in the processing cost by replacing the subquery with the view. You may create it.

前記算出部は、前記物理的なビューを前記複数のデータベースのいずれかに作成した場合に当該ビューに対応する前記問合せ文を実行するときの、前記データベース管理装置と前記複数のデータベースとの間の通信量の予測値を算出し、前記作成部は、算出された前記予測値が相対的に少なくなる前記データベースに前記物理的なビューを作成してもよい。
前記算出部は、複数の前記問合せ文のそれぞれについて、前記副問合せに対応するビューを作成した前記データベースにおいて処理が行われる範囲を特定し、特定した範囲に対応するデータに基づいて、処理コストの予測値を算出し、当該処理コストの予測値に基づいて前記通信量の予測値を補正し、前記作成部は、補正後の前記通信量の予測値が相対的に少なくなる前記データベースに前記物理的なビューを作成してもよい。
When the calculation unit creates the physical view in any of the plurality of databases and executes the query statement corresponding to the view, the calculation unit is between the database management device and the plurality of databases. The predicted value of the communication volume may be calculated, and the creating unit may create the physical view in the database in which the calculated predicted value is relatively small.
The calculation unit specifies a range in which processing is performed in the database that creates a view corresponding to the subquery for each of the plurality of query statements, and based on the data corresponding to the specified range, the processing cost is calculated. The predicted value is calculated, the predicted value of the communication amount is corrected based on the predicted value of the processing cost, and the creation unit performs the physical in the database in which the predicted value of the corrected communication amount is relatively small. View may be created.

前記作成部は、前記データベース管理装置の記憶部に前記物理的なビューを作成してもよい。 The creation unit may create the physical view in the storage unit of the database management device.

本発明の第2の態様に係るデータベース管理方法は、コンピュータが実行する、複数のデータベースの少なくともいずれかに対応する複数の問合せ文を取得するステップと、前記複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定するステップと、特定された前記副問合せに対応する物理的なビューを作成するステップと、前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデルを更新するステップと、を備える。 The database management method according to the second aspect of the present invention includes a step of acquiring a plurality of query statements corresponding to at least one of a plurality of databases executed by a computer, and each of the plurality of databases. At least a part of the plurality of query statements acquired based on a physical model that manages the storage location of each of the plurality of tables and a logical model that manages the virtual table referenced by the user, including the view of the table. Among the subqueries commonly included in the query statement of, the step of identifying a subquery that refers to a plurality of the databases, the step of creating a physical view corresponding to the identified subquery, and the view are Once created, it comprises a step of updating the logical model so that the user can refer to the created view.

本発明の第3の態様に係るデータベース管理プログラムは、コンピュータを、複数のデータベースの少なくともいずれかに対応する複数の問合せ文を取得する取得部、前記複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定する特定部、特定された前記副問合せに対応する物理的なビューを作成する作成部、及び、前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデルを更新する更新部、として機能させる。 The database management program according to the third aspect of the present invention includes an acquisition unit for acquiring a plurality of query statements corresponding to at least one of a plurality of databases, and a plurality of databases included in each of the plurality of databases. Queries of at least some of the retrieved query statements based on a physical model that manages each storage location of the table and a logical model that manages the virtual table referenced by the user, including views of the table. Among the subqueries commonly included in the statement, a specific part that identifies a subquery that refers to a plurality of the databases, a creation part that creates a physical view corresponding to the specified subquery, and the view When created, the created view is made to function as an update unit that updates the logical model so that the user can refer to it.

本発明によれば、複数のデータベースを使用する環境において、問合せ文の実行性能を向上させることができるという効果を奏する。 According to the present invention, there is an effect that the execution performance of a query statement can be improved in an environment in which a plurality of databases are used.

第1実施形態に係る仮想データベースシステムの構成を示す図である。It is a figure which shows the structure of the virtual database system which concerns on 1st Embodiment. 第1実施形態に係るデータベース管理装置の構成を示す図である。It is a figure which shows the structure of the database management apparatus which concerns on 1st Embodiment. 第1実施形態に係る問合せ文の一例を示す図である。It is a figure which shows an example of the inquiry sentence which concerns on 1st Embodiment. 図3に示す問合せ文に対応する実行計画を示す図である。It is a figure which shows the execution plan corresponding to the inquiry statement shown in FIG. 第1実施形態に係るマテリアライズドビューの作成に係る処理の流れを示すフローチャートである。It is a flowchart which shows the flow of the process which concerns on the creation of the materialized view which concerns on 1st Embodiment. 第2実施形態に係るデータベース管理装置の構成を示す図である。It is a figure which shows the structure of the database management apparatus which concerns on 2nd Embodiment.

<第1実施形態>
[仮想データベースシステムSの概要]
図1は、第1実施形態に係る仮想データベースシステムSの構成を示す図である。仮想データベースシステムSは、データベース11を物理的に格納する複数の記憶装置1と、データベース管理装置2と、ユーザ端末3とを備え、複数のデータベース11を仮想的に統合するシステムである。なお、図1において、ユーザ端末3は1台のみ示されているが、複数のユーザ端末3がデータベース管理装置2に接続されているものとする。
<First Embodiment>
[Overview of virtual database system S]
FIG. 1 is a diagram showing a configuration of a virtual database system S according to the first embodiment. The virtual database system S is a system that includes a plurality of storage devices 1 that physically store the database 11, a database management device 2, and a user terminal 3, and virtually integrates the plurality of databases 11. Although only one user terminal 3 is shown in FIG. 1, it is assumed that a plurality of user terminals 3 are connected to the database management device 2.

データベース管理装置2は、データベース11に格納されているテーブルを示す情報であるスキーマ情報として、物理モデルと、論理モデルとを記憶している。物理モデルは、テーブルの物理的な格納場所を示すモデルである。論理モデルは、ユーザ端末3が参照可能な仮想的なテーブルを管理するモデルであり、仮想的なテーブルと、物理モデルが示すテーブルとの関連付けを行う。ここで、仮想的なテーブルには、データベース管理装置2が作成したビューが含まれる。データベース管理装置2は、ユーザ端末3から論理モデルに対応する問合せ文を取得すると、物理モデルを参照し、当該問合せ文に対応する1以上のデータベース11を特定する。 The database management device 2 stores a physical model and a logical model as schema information which is information indicating a table stored in the database 11. A physical model is a model that shows the physical storage location of a table. The logical model is a model that manages a virtual table that can be referred to by the user terminal 3, and associates the virtual table with the table indicated by the physical model. Here, the virtual table includes a view created by the database management device 2. When the database management device 2 acquires a query statement corresponding to the logical model from the user terminal 3, it refers to the physical model and identifies one or more databases 11 corresponding to the query statement.

データベース管理装置2は、特定したデータベース11からデータを取得して問合せ文に対応する演算を実行し、実行結果をユーザ端末3に出力する。これにより、ユーザは、データベース11の物理的な位置を意識することなく複数のデータベース11に格納されているデータを参照することができる。 The database management device 2 acquires data from the specified database 11, executes an operation corresponding to the query statement, and outputs the execution result to the user terminal 3. As a result, the user can refer to the data stored in the plurality of databases 11 without being aware of the physical position of the database 11.

データベース管理装置2は、問合せ文に対応する複数のテーブルが同一のデータベース11に格納されている場合に、問合せ文の実行時のデータ通信量を減らすために、問合せ文に対応する処理を当該データベース11上で行わせる。また、データベース管理装置2は、問合せ文に対応する複数のテーブルが同一のデータベース11に格納されていない場合に、問合せ文に対応するテーブルをデータベース管理装置2が取得し、データベース管理装置2において問合せ文に対応する処理を行う。このため、問合せ文に対応するテーブルが同一のデータベース11に格納されていない場合には、データ通信量が増加し、問合せ文の実行性能が悪化するという問題が発生する。 When a plurality of tables corresponding to a query statement are stored in the same database 11, the database management device 2 performs a process corresponding to the query statement in order to reduce the amount of data communication at the time of executing the query statement. Let it be done on 11. Further, in the database management device 2, when a plurality of tables corresponding to the query statements are not stored in the same database 11, the database management device 2 acquires the tables corresponding to the query statements, and the database management device 2 inquires. Performs processing corresponding to the statement. Therefore, when the table corresponding to the query statement is not stored in the same database 11, there arises a problem that the amount of data communication increases and the execution performance of the query statement deteriorates.

このような問題に対して、本実施形態に係るデータベース管理装置2は、ユーザ端末3から取得した複数の問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数のデータベース11を参照する副問合せを特定する。そして、データベース管理装置2は、自身の記憶領域に、特定した副問合せに対応する物理的なビューであるマテリアライズドビューを作成する。データベース管理装置2は、作成されたマテリアライズドビューをユーザが参照可能に論理モデルを更新する。このようにすることで、データベース管理装置2は、任意の複数のデータベース11を使用する環境において、問合せ文の実行性能を向上させることができる。
続いて、データベース管理装置2の構成を説明する。
In response to such a problem, the database management device 2 according to the present embodiment has a plurality of databases 11 among subqueries commonly included in at least a part of the query statements acquired from the user terminal 3. Identify the subquery that references. Then, the database management device 2 creates a materialized view, which is a physical view corresponding to the specified subquery, in its own storage area. The database management device 2 updates the logical model so that the user can refer to the created materialized view. By doing so, the database management device 2 can improve the execution performance of the query statement in an environment in which an arbitrary plurality of databases 11 are used.
Subsequently, the configuration of the database management device 2 will be described.

[データベース管理装置2の構成]
図2は、第1実施形態に係るデータベース管理装置2の構成を示す図である。データベース管理装置2は、コンピュータであり、LAN(Local Area Network)等を介して、複数の記憶装置1と、ユーザ端末3とに通信可能に接続されている。
[Configuration of database management device 2]
FIG. 2 is a diagram showing a configuration of the database management device 2 according to the first embodiment. The database management device 2 is a computer, and is communicably connected to a plurality of storage devices 1 and a user terminal 3 via a LAN (Local Area Network) or the like.

データベース管理装置2は、図2に示すように、記憶部21と、制御部22とを備える。
記憶部21は、例えば、ROM(Read Only Memory)及びRAM(Random Access Memory)等である。記憶部21は、データベース管理装置2を機能させるための各種プログラムを記憶する。例えば、記憶部21は、データベース管理装置2の制御部22を、後述する受付部221、実行部222、取得部223、特定部224、算出部225、作成部226及び更新部227として機能させるデータベース管理プログラムを記憶する。
As shown in FIG. 2, the database management device 2 includes a storage unit 21 and a control unit 22.
The storage unit 21 is, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), or the like. The storage unit 21 stores various programs for operating the database management device 2. For example, the storage unit 21 causes the control unit 22 of the database management device 2 to function as a reception unit 221, an execution unit 222, an acquisition unit 223, a specific unit 224, a calculation unit 225, a creation unit 226, and an update unit 227, which will be described later. Remember the management program.

また、記憶部21は、データベース11に格納されているテーブルを示す情報であるスキーマ情報として、物理モデルPMと論理モデルLMとを記憶する。物理モデルPMは、複数のデータベース11に格納されている複数のテーブルの格納先を管理する。具体的には、物理モデルPMは、データベース11に格納されているテーブルを識別するテーブル名と、当該テーブルが格納されているデータベース11を識別するデータベース識別情報とを関連付けて記憶する。 Further, the storage unit 21 stores the physical model PM and the logical model LM as schema information which is information indicating the table stored in the database 11. The physical model PM manages the storage destinations of a plurality of tables stored in the plurality of databases 11. Specifically, the physical model PM stores the table name that identifies the table stored in the database 11 and the database identification information that identifies the database 11 in which the table is stored in association with each other.

論理モデルLMは、ユーザが参照する仮想テーブルを管理する。論理モデルLMは、仮想テーブルを識別するテーブル名と、当該仮想テーブルの構成を示す情報とを関連付けて記憶する。ここで、仮想テーブルの構成を示す情報は、物理モデルPMが示すテーブル名、又は、データベース管理装置2や、ユーザ端末3のユーザによって作成されたビューである。ここで、ビューには、物理的なビューであるマテリアライズドビューだけではなく、副問合せの内容を記述した論理的なビューが含まれていてもよい。 The logical model LM manages the virtual table referenced by the user. The logical model LM stores the table name that identifies the virtual table and the information indicating the configuration of the virtual table in association with each other. Here, the information indicating the configuration of the virtual table is the table name indicated by the physical model PM, or the view created by the user of the database management device 2 or the user terminal 3. Here, the view may include not only a materialized view, which is a physical view, but also a logical view that describes the contents of a subquery.

制御部22は、例えばCPU(Central Processing Unit)である。制御部22は、記憶部21に記憶されている各種プログラムを実行することにより、データベース管理装置2に係る機能を制御する。制御部22は、データベース管理プログラムを実行することにより、受付部221、実行部222、取得部223、特定部224、算出部225、作成部226及び更新部227として機能する。 The control unit 22 is, for example, a CPU (Central Processing Unit). The control unit 22 controls the functions related to the database management device 2 by executing various programs stored in the storage unit 21. By executing the database management program, the control unit 22 functions as a reception unit 221, an execution unit 222, an acquisition unit 223, a specific unit 224, a calculation unit 225, a creation unit 226, and an update unit 227.

受付部221は、ユーザ端末3から複数のデータベース11の少なくともいずれかに対応する問合せ文を受け付ける。具体的には、受付部221は、ユーザ端末3から、複数の問合せ文として、SQL(Structured Query Language)で記述された命令文を受け付ける。 The reception unit 221 receives an inquiry statement corresponding to at least one of the plurality of databases 11 from the user terminal 3. Specifically, the reception unit 221 receives a command statement described in SQL (Structured Query Language) as a plurality of query statements from the user terminal 3.

実行部222は、受付部221により受け付けられた問合せ文に対応する処理を行う。まず、実行部222は、取得された問合せ文に対応する実行計画を示す実行計画情報を生成する。ここで、実行計画は木構造を有している。 The execution unit 222 performs a process corresponding to the inquiry statement received by the reception unit 221. First, the execution unit 222 generates execution plan information indicating an execution plan corresponding to the acquired query statement. Here, the execution plan has a tree structure.

図3は、第1実施形態に係る問合せ文の一例を示す図である。図3では、(a)、(b)に示すように2つの問合せ文を示している。図4(a)、(b)は、図3(a)、(b)に示す問合せ文に対応する実行計画を示す図である。図4に示されるように、実行計画は木構造であることが確認できる。また、図4に示されるように、楕円内には、問合せ文によって実行される処理の種類が記載されている。また、処理の種類がテーブルのスキャンである場合には、処理の後にスキャン対象となるテーブル名(例えば、customerやorders)が示されている。なお、図4に示される実行計画では、テーブルから選択するカラムの指定や、テーブルから行を選択する条件といった処理の内容については記載を省略している。 FIG. 3 is a diagram showing an example of an inquiry sentence according to the first embodiment. In FIG. 3, two query statements are shown as shown in (a) and (b). 4 (a) and 4 (b) are diagrams showing an execution plan corresponding to the query statements shown in FIGS. 3 (a) and 3 (b). As shown in FIG. 4, it can be confirmed that the execution plan has a tree structure. Further, as shown in FIG. 4, the type of processing executed by the query statement is described in the ellipse. When the type of processing is table scanning, the name of the table to be scanned (for example, customers or orders) is shown after the processing. In the execution plan shown in FIG. 4, the description of the processing contents such as the specification of the column to be selected from the table and the condition for selecting the row from the table is omitted.

実行部222は、実行計画に基づいて、取得された問合せ文に対応する処理を行う。例えば、実行部222は、問合せ文に対応するテーブルが同一のデータベース11に格納されている場合に、問合せ文に対応する処理を当該データベース11上で行わせる。また、実行部222は、問合せ文に対応するテーブルが同一のデータベース11に格納されていない場合に、問合せ文に対応するテーブルをデータベース11から取得し、当該テーブルを用いて問合せ文に対応する処理を行う。 The execution unit 222 performs a process corresponding to the acquired inquiry statement based on the execution plan. For example, when the table corresponding to the query statement is stored in the same database 11, the execution unit 222 causes the processing corresponding to the query statement to be performed on the database 11. Further, when the table corresponding to the query statement is not stored in the same database 11, the execution unit 222 acquires the table corresponding to the query statement from the database 11 and processes the table corresponding to the query statement using the table. I do.

また、実行部222は、問合せ文に対応するマテリアライズドビューが記憶部21に記憶されている場合に、当該マテリアライズドビューを参照してデータを取得し、当該データを用いて問合せ文に対応する処理を行う。 Further, when the materialized view corresponding to the query statement is stored in the storage unit 21, the execution unit 222 acquires data by referring to the materialized view, and uses the data to perform processing corresponding to the query statement. Do.

実行部222は、問合せ文の実行結果をユーザ端末3に出力する。また、実行部222は、取得された問合せ文と、当該問合せ文に対応する実行計画と、当該問合せ文を受け付けた日時とを関連付けて記憶部21に記憶させる。 The execution unit 222 outputs the execution result of the inquiry statement to the user terminal 3. Further, the execution unit 222 stores the acquired inquiry statement, the execution plan corresponding to the inquiry statement, and the date and time when the inquiry statement is received in the storage unit 21 in association with each other.

取得部223は、複数のデータベース11の少なくともいずれかに対応する複数の問合せ文を取得する。具体的には、取得部223は、記憶部21に記憶されている複数の問合せ文と、当該問合せ文に関連付けられている実行計画とを所定時間(例えば1週間)おきに取得する。ここで、取得部223は、記憶部21に記憶されている複数の問合せ文のうち、現在時刻から所定期間以内に受付部221が受け付けた問合せ文を取得してもよい。このようにすることで、データベース管理装置2は、直近の問合せ文の使用傾向に対応してマテリアライズドビューを作成することができる。 The acquisition unit 223 acquires a plurality of query statements corresponding to at least one of the plurality of databases 11. Specifically, the acquisition unit 223 acquires a plurality of inquiry statements stored in the storage unit 21 and an execution plan associated with the inquiry statement at predetermined time intervals (for example, one week). Here, the acquisition unit 223 may acquire the inquiry sentence received by the reception unit 221 within a predetermined period from the current time among the plurality of inquiry sentences stored in the storage unit 21. By doing so, the database management device 2 can create a materialized view corresponding to the usage tendency of the latest query statement.

特定部224は、取得部223によって取得された複数の問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せ文を特定する。例えば、特定部224は、複数の問合せ文とともに取得された複数の実行計画の少なくとも一部の実行計画に共通に含まれ、副問合せの構造を示す共通部分木を特定し、当該共通部分木に対応する副問合せを特定する。特定部224は、記憶部21に記憶されている論理モデルLM及び物理モデルPMに基づいて、特定された副問合せ文のうち、複数のデータベース11を参照する副問合せを特定する。 The identification unit 224 specifies a subquery statement commonly included in at least a part of the query statements acquired by the acquisition unit 223. For example, the specific unit 224 identifies a common subtree that is commonly included in at least a part of the execution plans of the plurality of execution plans acquired together with the plurality of query statements and indicates the structure of the subquery, and is used in the common subtree. Identify the corresponding subquery. The identification unit 224 identifies a subquery that refers to a plurality of databases 11 among the specified subquery statements based on the logical model LM and the physical model PM stored in the storage unit 21.

算出部225は、特定された副問合せの処理コストと、当該副問合せをマテリアライズドビューに置き換えた場合の当該マテリアライズドビューの処理コストとを算出する。ここで、処理コストには、副問合せを実行する場合の計算コストと、通信ネットワーク等を介してデータを取得する時間を示す通信コストとが含まれる。例えば、算出部225は、特定された副問合せが参照するテーブルのレコード数に基づいて副問合せの計算コストを算出するとともに、当該副問合せの結果得られるレコード数又はデータ量に基づいて通信コストを算出する。そして、算出部225は、算出した計算コストと通信コストとに基づいて、副問合せの処理コストを算出する。 The calculation unit 225 calculates the processing cost of the specified subquery and the processing cost of the materialized view when the subquery is replaced with the materialized view. Here, the processing cost includes a calculation cost when executing a subquery and a communication cost indicating the time for acquiring data via a communication network or the like. For example, the calculation unit 225 calculates the calculation cost of the subquery based on the number of records in the table referenced by the specified subquery, and calculates the communication cost based on the number of records or the amount of data obtained as a result of the subquery. calculate. Then, the calculation unit 225 calculates the processing cost of the subquery based on the calculated calculation cost and the communication cost.

同様に、算出部225は、副問合せをマテリアライズドビューに置き換えた場合における、当該マテリアライズドビューの処理コストを算出する。ここで、マテリアライズドビューは、テーブルを連結する処理が不要になることから、副問合せを実行する場合に比べて計算コストが著しく小さくなる。また、マテリアライズドビューを記憶部21に記憶された場合には、マテリアライズドビューに対応するデータを取得するときの通信コストが著しく小さくなる。 Similarly, the calculation unit 225 calculates the processing cost of the materialized view when the subquery is replaced with the materialized view. Here, since the materialized view does not require the process of concatenating the tables, the calculation cost is significantly smaller than that in the case of executing the subquery. Further, when the materialized view is stored in the storage unit 21, the communication cost when acquiring the data corresponding to the materialized view is remarkably reduced.

また、算出部225は、取得部223によって取得された複数の問合せ文に含まれている副問合せの割合に基づいて、副問合せの実行頻度を特定する。そして、算出部225は、副問合せの実行頻度と、副問合せの処理コストと、当該副問合せに対応するマテリアライズドビューの処理コストとに基づいて、副問合せをマテリアライズドビューに置き換えることによる処理コストの低下量の期待値を算出する。ここで、期待値とは、副問合せの実行頻度に基づく確率を重みとして加味した処理コストの重み付き平均である。算出部225は、実行頻度が非定常的に変動する場合は、その変動を考慮して確率を変動させ、当該確率に基づいて期待値を算出しても構わない。 Further, the calculation unit 225 specifies the execution frequency of the subquery based on the ratio of the subquery included in the plurality of query statements acquired by the acquisition unit 223. Then, the calculation unit 225 reduces the processing cost by replacing the subquery with the materialized view based on the execution frequency of the subquery, the processing cost of the subquery, and the processing cost of the materialized view corresponding to the subquery. Calculate the expected value of the quantity. Here, the expected value is a weighted average of the processing costs in which the probability based on the execution frequency of the subquery is added as a weight. When the execution frequency fluctuates non-steadily, the calculation unit 225 may fluctuate the probability in consideration of the fluctuation and calculate the expected value based on the probability.

作成部226は、特定部224により複数のデータベース11を参照すると特定された副問合せに対応するマテリアライズドビューを作成する。具体的には、作成部226は、算出された副問合せの処理コストと、当該副問合せをマテリアライズドビューに置き換えた場合の当該ビューの処理コストと、副問合せの実行頻度とに基づいて、マテリアライズドビューに置き換えることによって処理コストの低下量の期待値が大きい順にマテリアライズドビューを作成する。 The creation unit 226 creates a materialized view corresponding to the subquery specified by the specific unit 224 to refer to the plurality of databases 11. Specifically, the creation unit 226 is based on the calculated processing cost of the subquery, the processing cost of the view when the subquery is replaced with the materialized view, and the execution frequency of the subquery, and the materialized view. By replacing with, materialized views are created in descending order of expected value of reduction in processing cost.

ここで、作成部226は、データベース管理装置2の記憶部21の記憶可能容量を特定する。そして、作成部226は、特定した記憶可能容量を超えない範囲で、マテリアライズドビューを記憶部21に作成する。このようにすることで、データベース管理装置2は、マテリアライズドビューを作成中に記憶部21の記憶可能容量が足りなくなることを防止することができる。 Here, the creation unit 226 specifies the storable capacity of the storage unit 21 of the database management device 2. Then, the creation unit 226 creates a materialized view in the storage unit 21 within a range that does not exceed the specified storable capacity. By doing so, the database management device 2 can prevent the storage capacity of the storage unit 21 from becoming insufficient while creating the materialized view.

なお、作成部226は、マテリアライズドビューをデータベース管理装置2の記憶部21に作成したが、これに限らない。算出部225は、マテリアライズドビューを複数のデータベース11のいずれかに作成した場合に当該ビューに対応する問合せ文を実行するときのデータベース管理装置2と複数のデータベース11との間の通信量の予測値を算出してもよい。ここで、通信量は、過去の通信の統計情報、例えばスループットの平均、又は信頼区間の上限値と下限値との間の情報に基づいて算出されるようにしてもよい。そして、作成部226は、算出された予測値が相対的に小さくなるデータベース11にマテリアライズドビューを作成してもよい。 The creation unit 226 creates the materialized view in the storage unit 21 of the database management device 2, but the present invention is not limited to this. When the materialized view is created in any of the plurality of databases 11, the calculation unit 225 predicts the amount of communication between the database management device 2 and the plurality of databases 11 when executing the query statement corresponding to the view. May be calculated. Here, the communication volume may be calculated based on the statistical information of past communication, for example, the average throughput, or the information between the upper limit value and the lower limit value of the confidence interval. Then, the creation unit 226 may create a materialized view in the database 11 in which the calculated predicted value is relatively small.

また、算出部225は、算出する予測値について、通信量だけではなく、処理コストを加味してもよい。例えば、算出部225は、複数の問合せ文のそれぞれについて、副問合せに対応するビューを作成したデータベース11において処理が行われる範囲を特定し、特定した範囲に対応するデータに基づいて処理コストの予測値を算出し、当該処理コストの予測値に基づいて通信量の予測値を補正してもよい。そして、作成部226は、補正後の通信量の予測値が相対的に小さくなるデータベース11にマテリアライズドビューを作成してもよい。 Further, the calculation unit 225 may consider not only the communication amount but also the processing cost for the predicted value to be calculated. For example, the calculation unit 225 specifies the range to be processed in the database 11 that creates the view corresponding to the subquery for each of the plurality of query statements, and predicts the processing cost based on the data corresponding to the specified range. The value may be calculated and the predicted value of the communication volume may be corrected based on the predicted value of the processing cost. Then, the creation unit 226 may create a materialized view in the database 11 in which the predicted value of the corrected communication amount is relatively small.

例えば、マテリアライズドビューを複数のデータベース11のいずれかに作成した場合、計算コストが低減する場合がある。例えば、副問合せが入れ子構造になっており、かつ、マテリアライズドビューに対応する副問合せの親に、マテリアライズドビューを配置したデータベース内のテーブルとの結合処理に関する副問合せ(親副問合せ)がある場合、計算コストが低減する。また、この場合、データが当該親副問合せにより絞り込まれることにより、データベース管理装置2とマテリアライズドビューを配置したデータベースとの間の通信量がさらに小さくなる場合がある。 For example, when a materialized view is created in any of a plurality of databases 11, the calculation cost may be reduced. For example, if the subquery is nested and the parent of the subquery corresponding to the materialized view has a subquery (parent subquery) related to join processing with the table in the database in which the materialized view is placed. Calculation costs are reduced. Further, in this case, the amount of communication between the database management device 2 and the database in which the materialized view is arranged may be further reduced because the data is narrowed down by the parent / subquery.

上記のケースを考慮するために、算出部225は、各問合せについて、共通部分木から根の方向に遡って、共通部分木を内包するような部分木を逐次的に参照し、マテリアライズドビューを配置したデータベース内のテーブルのみで完結する範囲を探索する。そして、算出部225は、探索の結果、共通部分木を包含し、マテリアライズドビューを配置したデータベース内のテーブルのみで完結する部分木があれば、当該部分木のレコード数又はデータ量を参照して、処理コストの予測値を算出する。具体的には、算出部225は、まず、計算コストについて、予測値を計算する上で参照するレコード数を、当該部分木の各ノードのレコード数の総和に対して、共通部分木に対応するレコード数の和に関する部分をマテリアライズドビューから取得するレコード数に置き換えたレコード数の和によって代替する。続いて、算出部225は、通信コストについて、予測値を計算する上で参照するレコード数又はデータ量を、当該部分木に対応するレコード数又はデータ量によって代替する。 In order to consider the above case, the calculation unit 225 sequentially refers to the subtree containing the intersection tree from the common subtree in the direction of the root for each query, and arranges the materialized view. Search the range that can be completed only by the table in the database. Then, as a result of the search, the calculation unit 225 refers to the number of records or the amount of data of the subtree if there is a subtree that includes the common subtree and is completed only by the table in the database in which the materialized view is arranged. , Calculate the predicted value of the processing cost. Specifically, the calculation unit 225 first corresponds to the common subtree with respect to the total number of records of each node of the subtree with respect to the number of records referred to in calculating the predicted value for the calculation cost. The part related to the sum of the number of records is replaced by the sum of the number of records replaced with the number of records obtained from the materialized view. Subsequently, the calculation unit 225 substitutes the number of records or the amount of data referred to in calculating the predicted value for the communication cost by the number of records or the amount of data corresponding to the subtree.

ここで、作成部226は、データベース管理装置2の記憶部21の記憶可能容量を超えない範囲でマテリアライズドビューを記憶部21に作成した結果、記憶部21に作成できなかったマテリアライズドビューを、データベース11に作成するようにしてもよい。 Here, as a result of creating the materialized view in the storage unit 21 within the range not exceeding the storage capacity of the storage unit 21 of the database management device 2, the creation unit 226 creates the materialized view in the storage unit 21 and creates the materialized view in the database 11 It may be created in.

また、作成部226は、データベース管理装置2の記憶部21に自動的にマテリアライズドビューを作成することとしたが、これに限らない。作成部226は、マテリアライズドビューを作成するか否かの指示をユーザ端末3から受け付けてもよい。そして、作成部226は、マテリアライズドビューの作成を指示されたことに応じて、マテリアライズドビューを作成してもよい。また、作成部226は、データベース管理装置2の記憶部21と、データベース11とに同じマテリアライズドビューを作成してもよい。 Further, the creation unit 226 has decided to automatically create a materialized view in the storage unit 21 of the database management device 2, but the present invention is not limited to this. The creation unit 226 may receive an instruction from the user terminal 3 as to whether or not to create the materialized view. Then, the creation unit 226 may create the materialized view in response to the instruction to create the materialized view. Further, the creation unit 226 may create the same materialized view in the storage unit 21 of the database management device 2 and the database 11.

また、作成部226は、既に記憶部21に作成されているマテリアライズドビューの評価を行うようにしてもよい。そして、作成部226は、先入先出法、LRU(Least Recently Used)方式、又はLFU(Least Frequently Used)方式によりマテリアライズドビューを記憶部21から削除してもよい。また、作成部226は、処理コストの低下量の期待値が相対的に小さいマテリアライズドビューを記憶部21から削除してもよい。このようにすることで、データベース管理装置2は、処理コストの低下量の期待値が小さいマテリアライズドビューを記憶部21から削除し、記憶部21に、処理コストの低下量の期待値が大きいマテリアライズドビューを効率的に配置することができる。 Further, the creation unit 226 may evaluate the materialized view already created in the storage unit 21. Then, the creating unit 226 may delete the materialized view from the storage unit 21 by the first-in first-out method, the LRU (Least Recently Used) method, or the LFU (Least Frequently Used) method. Further, the creation unit 226 may delete the materialized view from the storage unit 21 in which the expected value of the reduction in the processing cost is relatively small. By doing so, the database management device 2 deletes the materialized view from the storage unit 21 having a small expected value of the reduction amount of the processing cost, and the materialized view having a large expected value of the reduction amount of the processing cost in the storage unit 21. Can be placed efficiently.

また、作成部226は、既に記憶部21に作成されているマテリアライズドビューを全て削除した後、処理コストの低下量の期待値が大きい順にマテリアライズドビューを作成してもよい。 Further, the creation unit 226 may create the materialized views in descending order of the expected value of the reduction amount of the processing cost after deleting all the materialized views already created in the storage unit 21.

更新部227は、マテリアライズドビューが作成されると、作成されたマテリアライズドビューを実行部222及びユーザ端末3のユーザが参照可能に物理モデルPM及び論理モデルLMを更新する。また、更新部227は、マテリアライズドビューが作成されたことを示す情報と、当該マテリアライズドビューに対応する副問合せを示す情報とを関連付けてユーザ端末3に出力してもよい。これにより、ユーザ端末3のユーザは、当該副問合せを含む問合せ文を生成するときに、当該副問合せの代わりにマテリアライズドビューを指定して、実行部222における問合せ文の処理時間を短くすることができる。 When the materialized view is created, the update unit 227 updates the physical model PM and the logical model LM so that the user of the execution unit 222 and the user terminal 3 can refer to the created materialized view. Further, the update unit 227 may output the information indicating that the materialized view has been created and the information indicating the subquery corresponding to the materialized view to the user terminal 3 in association with each other. As a result, when the user of the user terminal 3 generates a query statement including the subquery, the materialized view can be specified instead of the subquery to shorten the processing time of the query statement in the execution unit 222. it can.

[マテリアライズドビューの作成に係る処理の流れ]
続いて、マテリアライズドビューの作成に係る処理の流れについて説明する。図5は、第1実施形態に係るマテリアライズドビューの作成に係る処理の流れを示すフローチャートである。
[Process flow related to materialized view creation]
Next, the flow of processing related to the creation of the materialized view will be described. FIG. 5 is a flowchart showing a flow of processing related to the creation of the materialized view according to the first embodiment.

まず、取得部223は、記憶部21に記憶されている、複数のデータベース11の少なくともいずれかに対応する複数の問合せ文と実行計画を取得する(S10)。
続いて、特定部224は、実行計画に基づいて、複数の問合せ文に共通に含まれる副問合せを特定する(S20)。
First, the acquisition unit 223 acquires a plurality of query statements and execution plans stored in the storage unit 21 corresponding to at least one of the plurality of databases 11 (S10).
Subsequently, the specifying unit 224 specifies a subquery commonly included in the plurality of query statements based on the execution plan (S20).

続いて、算出部225は、特定された副問合せの処理コスト、及び当該副問合せをマテリアライズドビューに置き換えた場合の処理コストを算出する(S30)。
続いて、作成部226は、特定された副問合せのうち、マテリアライズドビューに置き換えることによって処理コストの低下量の期待値が大きい副問合せから順にマテリアライズドビューを作成する(S40)。
Subsequently, the calculation unit 225 calculates the processing cost of the specified subquery and the processing cost when the subquery is replaced with the materialized view (S30).
Subsequently, the creation unit 226 creates the materialized view in order from the subquery with the largest expected value of the reduction in processing cost by replacing the specified subquery with the materialized view (S40).

続いて、作成部226は、データベース管理装置2の記憶部21に、次に作成する予定のマテリアライズドビューの記憶可能領域があるか否かを判定する(S50)。作成部226は、記憶可能領域があると判定すると、S40に処理を移し、次に作成する予定のマテリアライズドビューを作成する。また、作成部226は、記憶領域がないと判定すると、本フローチャートに係る処理を終了する。 Subsequently, the creation unit 226 determines whether or not the storage unit 21 of the database management device 2 has a storable area for the materialized view to be created next (S50). When the creation unit 226 determines that there is a storable area, the process is transferred to S40, and the materialized view to be created next is created. If the creation unit 226 determines that there is no storage area, the creation unit 226 ends the process related to this flowchart.

[第1実施形態における効果]
以上のとおり、第1実施形態に係るデータベース管理装置2は、複数のデータベース11の少なくともいずれかに対応する複数の問合せ文を取得し、当該複数の問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数のデータベース11を参照する副問合せを特定する。そして、データベース管理装置2は、特定された副問合せに対応するマテリアライズドビューを作成し、当該マテリアライズドビューをユーザ端末3のユーザが参照可能に論理モデルLMを更新する。このようにすることで、データベース管理装置2は、複数のデータベース11が同時に参照されることを抑制し、任意の複数のデータベースを使用する環境において、問合せ文の実行性能を向上させることができる。
[Effect in the first embodiment]
As described above, the database management device 2 according to the first embodiment acquires a plurality of query statements corresponding to at least one of the plurality of databases 11, and is common to at least a part of the query statements of the plurality of query statements. Among the included subqueries, the subqueries that refer to a plurality of databases 11 are specified. Then, the database management device 2 creates a materialized view corresponding to the specified subquery, and updates the logical model LM so that the user of the user terminal 3 can refer to the materialized view. By doing so, the database management device 2 can suppress that a plurality of databases 11 are referred to at the same time, and can improve the execution performance of the query statement in an environment in which a plurality of arbitrary databases are used.

<第2実施形態>
[データベース11の利用状況に基づいてテーブルを移行した後にマテリアライズドビューを作成する]
続いて、第2実施形態について説明する。第2実施形態に係る仮想データベースシステムSでは、データベース11の利用状況に基づいてテーブルを移行した後にマテリアライズドビューを作成する点で第1実施形態と異なる。以下に、第2実施形態に係る仮想データベースシステムSについて説明する。なお、第1実施形態と同じ部分については適宜説明を省略する。
<Second Embodiment>
[Create a materialized view after migrating the table based on the usage status of database 11]
Subsequently, the second embodiment will be described. The virtual database system S according to the second embodiment is different from the first embodiment in that a materialized view is created after migrating the tables based on the usage status of the database 11. The virtual database system S according to the second embodiment will be described below. The same parts as those in the first embodiment will be omitted as appropriate.

図6は、第2実施形態に係るデータベース管理装置2の構成を示す図である。図6に示されるように、データベース管理装置2の制御部22は、移行制御部228をさらに備える。 FIG. 6 is a diagram showing a configuration of the database management device 2 according to the second embodiment. As shown in FIG. 6, the control unit 22 of the database management device 2 further includes a transition control unit 228.

移行制御部228は、所定時間おきに記憶部21に記憶されている複数の問合せ文と、当該問合せ文に対応する実行計画を取得する。そして、移行制御部228は、取得した複数の問合せ文及び実行計画に基づいて、複数のテーブルの利用状況を特定する。 The transition control unit 228 acquires a plurality of inquiry statements stored in the storage unit 21 at predetermined time intervals and an execution plan corresponding to the inquiry statements. Then, the transition control unit 228 specifies the usage status of the plurality of tables based on the acquired plurality of inquiry statements and execution plans.

移行制御部228は、特定した複数のテーブルの利用状況に基づいて、複数のデータベース11のうち、現在格納されているデータベース11とは異なるデータベース11に移行するテーブルを移行対象テーブルとして特定する。 The migration control unit 228 specifies a table to be migrated to a database 11 different from the currently stored database 11 as a migration target table among the plurality of databases 11 based on the usage status of the specified plurality of tables.

移行制御部228は、特定された移行対象テーブルを移行先のデータベース11に移行する。具体的には、移行制御部228は、特定された移行対象テーブルを移行先のデータベース11に複製し、移行対象テーブルの複製が完了すると、移行元のデータベース11から、移行対象テーブルを消去する。 The migration control unit 228 migrates the specified migration target table to the migration destination database 11. Specifically, the migration control unit 228 replicates the specified migration target table to the migration destination database 11, and when the replication of the migration target table is completed, deletes the migration target table from the migration source database 11.

更新部227は、移行制御部228による移行対象テーブルの移行が完了すると、データベース管理装置2の物理モデルが示す移行対象テーブルの格納先を移行先のデータベースに更新する。 When the migration of the migration target table by the migration control unit 228 is completed, the update unit 227 updates the storage destination of the migration target table indicated by the physical model of the database management device 2 to the migration destination database.

このようにすることで、データベース管理装置2は、テーブルの利用状況に基づいて、テーブルを適切なデータベースに配置することができる。これにより、データベース管理装置2が、問合せ文をデータベース11に実行させる機会が増加するので、問合せ文の実行時のデータ通信量を削減し、問合せ文の実行性能を向上させることができる。 By doing so, the database management device 2 can arrange the table in an appropriate database based on the usage status of the table. As a result, the database management device 2 has more opportunities to execute the query statement in the database 11, so that the amount of data communication at the time of executing the query statement can be reduced and the execution performance of the query statement can be improved.

取得部223は、移行制御部228による移行対象テーブルの移行が完了し、更新部227により物理モデルが示す移行対象テーブルの格納先が更新された後、記憶部21から、複数の問合せ文及び実行計画を取得する。 After the migration of the migration target table by the migration control unit 228 is completed and the storage destination of the migration target table indicated by the physical model is updated by the update unit 227, the acquisition unit 223 executes a plurality of inquiry statements and executions from the storage unit 21. Get the plan.

特定部224は、更新部227により物理モデルが示す移行対象テーブルの格納先が更新された後に取得された複数の問合せ文に基づいて、複数のデータベース11を参照する副問合せを特定する。
そして、作成部226は、特定部224により複数のデータベース11を参照すると特定された副問合せに対応するマテリアライズドビューを作成する。
The identification unit 224 specifies a subquery that refers to a plurality of databases 11 based on a plurality of query statements acquired after the storage destination of the migration target table indicated by the physical model is updated by the update unit 227.
Then, the creation unit 226 creates a materialized view corresponding to the subquery specified by the specific unit 224 to refer to the plurality of databases 11.

[第2実施形態における効果]
以上説明したように、第2実施形態に係るデータベース管理装置2は、複数のテーブルの利用状況に基づいて、複数のデータベース11のうち、現在格納されているデータベース11とは異なるデータベース11に移行するテーブルを移行対象テーブルとして特定し、特定された移行対象テーブルを移行先のデータベース11に移行する。そして、データベース管理装置2は、移行対象テーブルの移行が完了し、物理モデルが示す移行対象テーブルの格納先が更新された後、取得された複数の問合せ文に基づいて、複数のデータベース11を参照する副問合せを特定し、当該副問合せに対応するマテリアライズドビューを作成する。
[Effect in the second embodiment]
As described above, the database management device 2 according to the second embodiment shifts to a database 11 different from the currently stored database 11 among the plurality of databases 11 based on the usage status of the plurality of tables. The table is specified as a migration target table, and the identified migration target table is migrated to the migration destination database 11. Then, after the migration of the migration target table is completed and the storage destination of the migration target table indicated by the physical model is updated, the database management device 2 refers to the plurality of databases 11 based on the acquired plurality of query statements. Identify the subquery to be used, and create a materialized view corresponding to the subquery.

このようにすることで、データベース管理装置2は、移行対象テーブルの移行後に異なるデータベース11に格納されている複数のテーブルを参照する副問合せ文を含む問合せ文の実行性能を向上させることができる。 By doing so, the database management device 2 can improve the execution performance of the query statement including the subquery statement that refers to a plurality of tables stored in different databases 11 after the migration of the migration target table.

以上、本発明を実施形態を用いて説明したが、本発明の技術的範囲は上記実施形態に記載の範囲には限定されない。上記実施形態に、多様な変更又は改良を加えることが可能であることが当業者に明らかである。例えば、上述の複数の実施形態を組み合わせてもよい。また、特に、装置の分散・統合の具体的な実施形態は以上に図示するものに限られず、その全部又は一部について、種々の付加等に応じて、又は、機能負荷に応じて、任意の単位で機能的又は物理的に分散・統合して構成することができる。 Although the present invention has been described above using the embodiments, the technical scope of the present invention is not limited to the scope described in the above embodiments. It will be apparent to those skilled in the art that various changes or improvements can be made to the above embodiments. For example, the plurality of embodiments described above may be combined. Further, in particular, the specific embodiments of the distribution / integration of the devices are not limited to those shown above, and all or a part thereof may be arbitrarily added according to various additions or functional loads. It can be functionally or physically distributed / integrated in units.

例えば、上述の実施形態では、データベース管理装置2が、問合せ文の実行管理及び移行制御を行うこととしたが、これに限らない。例えば、データベース管理装置2とは異なる1以上のサーバが、問合せ文の実行管理及びテーブルの移行制御を行ってもよい。 For example, in the above-described embodiment, the database management device 2 performs execution management and migration control of the query statement, but the present invention is not limited to this. For example, one or more servers different from the database management device 2 may perform execution management of query statements and table migration control.

1・・・記憶装置、11・・・データベース、2・・・データベース管理装置、21・・・記憶部、22・・・制御部、221・・・受付部、222・・・実行部、223・・・取得部、224・・・特定部、225・・・算出部、226・・・作成部、227・・・更新部、228・・・移行制御部、3・・・ユーザ端末、S・・・仮想データベースシステム 1 ... storage device, 11 ... database, 2 ... database management device, 21 ... storage unit, 22 ... control unit, 221 ... reception unit, 222 ... execution unit, 223 ... acquisition unit, 224 ... specific unit, 225 ... calculation unit, 226 ... creation unit, 227 ... update unit, 228 ... transition control unit, 3 ... user terminal, S・ ・ ・ Virtual database system

Claims (6)

データベースを管理するデータベース管理装置であって、
複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとを記憶する記憶部と、
複数の前記データベースの少なくともいずれかに対応する複数の問合せ文を取得する取得部と、
前記論理モデル及び前記物理モデルに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定する特定部と、
特定された前記副問合せに対応する物理的なビューを前記複数のデータベースのいずれかに作成した場合に当該ビューに対応する前記問合せ文を実行するときの、前記データベース管理装置と前記複数のデータベースとの間の通信量の予測値を、前記複数のデータベースのそれぞれに対して算出する算出部と、
前記算出部が算出した前記予測値が相対的に少なくなる前記データベースに、特定された前記副問合せに対応する物理的なビューを作成する作成部と、
前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデル及び前記物理モデルを更新する更新部と、
を備えるデータベース管理装置。
A database management device that manages databases
A storage unit that stores a physical model that manages the storage location of each of a plurality of tables included in each of the plurality of databases, and a logical model that manages a virtual table referenced by a user, including a view of the table. ,
An acquisition unit that acquires a plurality of query statements corresponding to at least one of the plurality of databases, and an acquisition unit.
A specific unit that identifies a plurality of subqueries that refer to the database among the subqueries commonly included in at least a part of the acquired query statements based on the logical model and the physical model. When,
When a physical view corresponding to the specified subquery is created in any of the plurality of databases, the database management device and the plurality of databases when executing the query statement corresponding to the view. A calculation unit that calculates the predicted value of the communication volume between the two databases for each of the plurality of databases.
A creation unit that creates a physical view corresponding to the specified subquery in the database in which the predicted value calculated by the calculation unit is relatively small.
When the view is created, an update unit that updates the logical model and the physical model so that the user can refer to the created view.
A database management device equipped with.
前記複数のテーブルの利用状況に基づいて、複数の前記データベースのうち、現在格納されているデータベースとは異なるデータベースに移行するテーブルを移行対象テーブルとして特定し、特定された前記移行対象テーブルを移行先のデータベースに移行する移行制御部をさらに備え、
前記更新部は、前記物理モデルが示す前記移行対象テーブルの格納先を前記移行先のデータベースに更新し、
前記特定部は、前記移行制御部による前記移行対象テーブルの移行が完了し、前記物理モデルが示す前記移行対象テーブルの格納先が更新された後、取得された複数の前記問合せ文に基づいて、複数の前記データベースを参照する副問合せを特定する、
請求項1に記載のデータベース管理装置。
Based on the usage status of the plurality of tables, among the plurality of the databases, the table to be migrated to the database different from the currently stored database is specified as the migration target table, and the identified migration target table is the migration destination. It also has a migration control unit that migrates to the database of
The update unit updates the storage destination of the migration target table indicated by the physical model to the database of the migration destination.
The specific unit is based on the plurality of query statements acquired after the migration of the migration target table by the migration control unit is completed and the storage destination of the migration target table indicated by the physical model is updated. Identify subqueries that reference multiple databases,
The database management device according to claim 1.
前記算出部は、特定された前記副問合せの処理コストと、当該副問合せを前記ビューに置き換えた場合の当該ビューの処理コストとを算出し、
前記作成部は、算出された前記副問合せの処理コストと、当該副問合せを前記ビューに置き換えた場合の当該ビューの処理コストとに基づいて、前記ビューに置き換えることによって処理コストの低下量の期待値が大きい順に当該ビューを作成する、
請求項1又は2に記載のデータベース管理装置。
The calculation unit calculates the processing cost of the specified subquery and the processing cost of the view when the subquery is replaced with the view .
Based on the calculated processing cost of the subquery and the processing cost of the view when the subquery is replaced with the view, the creating unit expects a reduction in processing cost by replacing the subquery with the view. Create the view in descending order of value,
The database management device according to claim 1 or 2.
前記算出部は、複数の前記問合せ文のそれぞれについて、前記副問合せに対応するビューを作成した前記データベースにおいて処理が行われる範囲を特定し、特定した範囲に対応するデータに基づいて、処理コストの予測値を算出し、当該処理コストの予測値に基づいて前記通信量の予測値を補正し、
前記作成部は、補正後の前記通信量の予測値が相対的に少なくなる前記データベースに前記物理的なビューを作成する、
請求項1から3のいずれか1項に記載のデータベース管理装置。
The calculation unit specifies a range in which processing is performed in the database that creates a view corresponding to the subquery for each of the plurality of query statements, and based on the data corresponding to the specified range, the processing cost is calculated. The predicted value is calculated, and the predicted value of the communication volume is corrected based on the predicted value of the processing cost.
The creation unit creates the physical view in the database in which the predicted value of the corrected communication volume is relatively small.
The database management device according to any one of claims 1 to 3.
コンピュータが実行する、
複数のデータベースの少なくともいずれかに対応する複数の問合せ文を取得するステップと、
前記複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定するステップと、
特定された前記副問合せに対応する物理的なビューを前記複数のデータベースのいずれかに作成した場合に当該ビューに対応する前記問合せ文を実行するときの、前記コンピュータと前記複数のデータベースとの間の通信量の予測値を、前記複数のデータベースのそれぞれに対して算出するステップと、
算出された前記予測値が相対的に少なくなる前記データベースに、特定された前記副問合せに対応する物理的なビューを作成するステップと、
前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデルを更新するステップと、
を備えるデータベース管理方法。
Computer runs,
Steps to get multiple query statements corresponding to at least one of multiple databases,
Obtained based on a physical model that manages the storage location of each of the plurality of tables included in each of the plurality of databases and a logical model that manages the virtual table referenced by the user, including the view of the table. A step of identifying a subquery that refers to a plurality of the databases among the subqueries commonly included in at least a part of the query statements of the plurality of the query statements.
Between the computer and the plurality of databases when executing the query statement corresponding to the view when a physical view corresponding to the specified subquery is created in any of the plurality of databases. And the step of calculating the predicted value of the communication volume for each of the plurality of databases.
A step of creating a physical view corresponding to the specified subquery in the database in which the calculated predicted value is relatively small, and
When the view is created, the step of updating the logical model so that the user can refer to the created view, and
Database management method with.
コンピュータを、
複数のデータベースの少なくともいずれかに対応する複数の問合せ文を取得する取得部、
前記複数のデータベースのそれぞれに含まれている複数のテーブルのそれぞれの格納先を管理する物理モデルと、前記テーブルのビューを含む、ユーザが参照する仮想テーブルを管理する論理モデルとに基づいて、取得された複数の前記問合せ文の少なくとも一部の問合せ文に共通に含まれる副問合せのうち、複数の前記データベースを参照する副問合せを特定する特定部、
特定された前記副問合せに対応する物理的なビューを前記複数のデータベースのいずれかに作成した場合に当該ビューに対応する前記問合せ文を実行するときの、前記コンピュータと前記複数のデータベースとの間の通信量の予測値を、前記複数のデータベースのそれぞれに対して算出する算出部、
前記算出部が算出した前記予測値が相対的に少なくなる前記データベースに、特定された前記副問合せに対応する物理的なビューを作成する作成部、及び、
前記ビューが作成されると、作成された前記ビューを前記ユーザが参照可能に前記論理モデルを更新する更新部、
として機能させるデータベース管理プログラム。
Computer,
Acquisition unit that acquires multiple query statements corresponding to at least one of multiple databases,
Obtained based on a physical model that manages the storage location of each of the plurality of tables included in each of the plurality of databases and a logical model that manages the virtual table referenced by the user, including the view of the table. A specific part that identifies a subquery that refers to a plurality of the databases among the subqueries commonly included in at least a part of the query statements of the plurality of the query statements.
Between the computer and the plurality of databases when executing the query statement corresponding to the view when a physical view corresponding to the specified subquery is created in any of the plurality of databases. A calculation unit that calculates the predicted value of the communication volume of the above-mentioned multiple databases for each of the plurality of databases.
A creation unit that creates a physical view corresponding to the specified subquery in the database in which the predicted value calculated by the calculation unit is relatively small, and a creation unit.
When the view is created, an update unit that updates the logical model so that the user can refer to the created view.
A database management program that functions as.
JP2017238546A 2017-12-13 2017-12-13 Database management device, database management method and database management program Active JP6898215B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2017238546A JP6898215B2 (en) 2017-12-13 2017-12-13 Database management device, database management method and database management program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2017238546A JP6898215B2 (en) 2017-12-13 2017-12-13 Database management device, database management method and database management program

Publications (2)

Publication Number Publication Date
JP2019106039A JP2019106039A (en) 2019-06-27
JP6898215B2 true JP6898215B2 (en) 2021-07-07

Family

ID=67061303

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2017238546A Active JP6898215B2 (en) 2017-12-13 2017-12-13 Database management device, database management method and database management program

Country Status (1)

Country Link
JP (1) JP6898215B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6971929B2 (en) * 2018-07-20 2021-11-24 Kddi株式会社 Inquiry statement output device and inquiry statement output method

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0293836A (en) * 1988-09-30 1990-04-04 Toshiba Corp Distributed data base controller
JP2006343798A (en) * 2005-06-07 2006-12-21 Hitachi Ltd Method, device and program for generating materialized view table
US7689538B2 (en) * 2006-01-26 2010-03-30 International Business Machines Corporation Autonomic recommendation and placement of materialized query tables for load distribution
JP6376947B2 (en) * 2014-11-06 2018-08-22 Kddi株式会社 Virtual database system management apparatus, management method, and management program

Also Published As

Publication number Publication date
JP2019106039A (en) 2019-06-27

Similar Documents

Publication Publication Date Title
US11347761B1 (en) System and methods for distributed database query engines
US11809408B2 (en) Incremental refresh of a materialized view
US20190377737A1 (en) Incremental and collocated redistribution for expansion of online shared nothing database
CN105630864B (en) Forced ordering of a dictionary storing row identifier values
US9934276B2 (en) Systems and methods for fault tolerant, adaptive execution of arbitrary queries at low latency
US10474648B2 (en) Migration of unified table metadata graph nodes
US7672930B2 (en) System and methods for facilitating a linear grid database with data organization by dimension
US8601007B2 (en) Net change notification based cached views with linked attributes
US8620903B2 (en) Database distribution system and methods for scale-out applications
CN108319656A (en) Realize the method, apparatus and calculate node and system that gray scale is issued
US11475006B2 (en) Query and change propagation scheduling for heterogeneous database systems
JP6642435B2 (en) Data processing device, data processing method, and program
JP6898215B2 (en) Database management device, database management method and database management program
JP6376947B2 (en) Virtual database system management apparatus, management method, and management program
CN109753533A (en) A kind of multi-source relevant database client development approach and device
JP6850720B2 (en) Query statement execution device, query statement execution method, and query statement execution program
JP2019066939A (en) Transfer management device and transfer management method
JP2017016208A (en) Virtual database system management apparatus, management method, and management program
US10558637B2 (en) Modularized data distribution plan generation
JP2018081603A (en) Kv data structure conversion device, kv data structure conversion method, and kv data structure conversion program
JP6812321B2 (en) Database management device, database management method, and database management program
US20170060932A1 (en) Action queue for hierarchy maintenance
CN112732704A (en) Data processing method, device and storage medium
Nevarez et al. How SQL Server Works

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20191206

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20200918

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20201020

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20201214

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20210518

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20210610

R150 Certificate of patent or registration of utility model

Ref document number: 6898215

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150