JP2001155028A - Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program - Google Patents

Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program

Info

Publication number
JP2001155028A
JP2001155028A JP33694199A JP33694199A JP2001155028A JP 2001155028 A JP2001155028 A JP 2001155028A JP 33694199 A JP33694199 A JP 33694199A JP 33694199 A JP33694199 A JP 33694199A JP 2001155028 A JP2001155028 A JP 2001155028A
Authority
JP
Japan
Prior art keywords
index
aggregation operation
operation result
aggregation
database
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
JP33694199A
Other languages
Japanese (ja)
Inventor
Kenichi Yamaguchi
健一 山口
Koji Kimura
耕治 木村
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.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
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 Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP33694199A priority Critical patent/JP2001155028A/en
Publication of JP2001155028A publication Critical patent/JP2001155028A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

PROBLEM TO BE SOLVED: To solve problems such as the deterioration of response performance or complexity of retrieval caused by input/output and calculation overhead since aggregate calculation operation is executed or stored in different tables each time of retrieval execution in conventional retrieval processing including aggregate calculation in a retrieval processing including aggregate calculation operation in a relational database system. SOLUTION: The result of arbitrary aggregate calculation is held in an index and the aggregate calculation operation result stored in the index is utilized for retrieving processing including aggregate calculation. Thus, it is not necessary to perform aggregate calculation in the case of retrieval execution.

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、リレーショナルデ
ータベースの集約演算処理方法に係り、特に集約演算を
含む検索処理に好適なデータベース処理方法に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to an aggregation operation processing method for a relational database, and more particularly to a database processing method suitable for search processing including an aggregation operation.

【0002】[0002]

【従来の技術】従来、リレーショナルデータベースシス
テムにおいて、指定された検索項目を集計するような集
約演算を含む検索処理がある。このような処理では利用
者が指定した検索条件のうち、インデクスを構成する項
目に対する条件についてインデクスを検索し、検索条件
と合致したインデクスキーエントリから目的のデータを
含むデータベース格納領域をアクセスして集約に必要な
項目の情報を取得し、集約演算を実行するという手順を
踏んでいる。そして、集約演算を含む検索処理を実行す
るたびに、データベースアクセスや集約演算を行ってい
た。また、検索処理実行のたびに集約演算処理を行わな
い方法として、特開平8−329101号公報記載のよ
うに、あらかじめ集約演算結果を取得し、演算結果を別
のテーブルとして保持しておく方法がある。
2. Description of the Related Art Conventionally, in a relational database system, there is a search process including an aggregation operation for counting specified search items. In such a process, among the search conditions specified by the user, an index is searched for the conditions for the items that make up the index, and the database storage area containing the target data is accessed from the index key entry that matches the search conditions and aggregated. , The information of the necessary items is obtained, and an aggregation operation is executed. Then, every time a search process including an aggregation operation is performed, a database access or an aggregation operation is performed. As a method of not performing the aggregation operation every time the search processing is executed, a method of acquiring the aggregation operation result in advance and holding the operation result as another table as described in Japanese Patent Application Laid-Open No. 8-329101 is known. is there.

【0003】[0003]

【発明が解決しようとする課題】従来技術のリレーショ
ナルデータベースにおける集約演算を含む検索処理で
は、集約演算を実行する際にデータベースアクセスによ
る入出力オーバヘッドや、集約演算にかかる演算オーバ
ヘッドが発生するため、入出力動作の多発や、大量デー
タの集約演算により検索処理の応答性能が劣化するとい
う問題があった。
In a search process including an aggregation operation in a conventional relational database, input / output overhead due to database access and operation overhead relating to the aggregation operation occur when executing the aggregation operation. There has been a problem that the response performance of the search processing deteriorates due to the frequent occurrence of the output operation and the aggregation operation of a large amount of data.

【0004】また、特開平8−329101号公報記載
のあらかじめ集約演算結果を取得し、別のデータベース
として保持しておく方法では、検索処理時に、どのデー
タベースを検索するかの切り替えが必要となるため、検
索方法が複雑になるという問題があった。
In the method described in Japanese Unexamined Patent Publication No. 8-329101, in which an aggregation operation result is acquired in advance and held as a separate database, it is necessary to switch which database is searched during search processing. However, there is a problem that a search method becomes complicated.

【0005】本発明の目的は、集約演算にかかる入出力
および演算のオーバヘッドを抑止し、集約演算を含む検
索処理の応答性能を向上させることにある。
SUMMARY OF THE INVENTION It is an object of the present invention to suppress input / output and operation overhead related to an aggregation operation, and to improve the response performance of search processing including the aggregation operation.

【0006】[0006]

【課題を解決するための手段】前記課題を解決するため
に、本発明は任意の集約演算の結果をインデクスに保持
し、集約演算を含む検索処理に対してこのインデクスに
格納した集約演算結果を利用するものである。
In order to solve the above-mentioned problems, the present invention holds the result of an arbitrary aggregation operation in an index and uses the result of the aggregation operation stored in the index for search processing including the aggregation operation. To use.

【0007】[0007]

【発明の実施の形態】以下に本発明の実施形態の概略を
説明する。インデクスはリレーショナルデータベース
(RDB)のアクセスを高速化するために設けられたも
のである。それは「キー値」とそのキー値を持つレコー
ドの格納位置を示す「アドレス情報」との対応表を持っ
ている。これは特に良く使われるキー項目について作ら
れる。RDBの検索時にはインデクスが参照される。し
たがって、この中に集約演算結果を合わせて記憶してお
けば、再度そのまま利用するか、またはそれを加工・編
集して利用する場合、検索実行の際にデータベースを検
索しての集約演算を行う必要がなくなり、集約演算の入
出力オーバヘッドや演算オーバヘッドを抑止することが
できる。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS An embodiment of the present invention will be described below. Indexes are provided to speed up access to a relational database (RDB). It has a correspondence table of "key values" and "address information" indicating storage positions of records having the key values. This is made for particularly frequently used key items. The index is referred to when searching the RDB. Therefore, if the result of the aggregation operation is also stored therein, if it is used again as it is, or if it is processed and edited and used, the aggregation operation is performed by searching the database at the time of executing the search. This eliminates the necessity, and can suppress the input / output overhead and the operation overhead of the aggregation operation.

【0008】本発明の実施形態における集約インデクス
は(ここで集約演算結果が格納されているインデクスを
集約インデクスと呼ぶ)、インデクス格納方法として、
インデクス格納領域に1または複数のキー項目を格納す
るインデクスキー格納領域と、利用者が指定した任意の
集約演算の演算結果を格納する集約演算結果格納領域
と、対応するデータベース中のデータの格納位置や前後
のインデクスエントリへのポインタを格納する制御情報
格納領域とを備え、これらの格納領域を組にして1つの
インデクスエントリを構成したものである。
[0008] The aggregate index in the embodiment of the present invention (here, the index in which the result of the aggregate operation is stored is referred to as an aggregate index) is described as an index storage method.
An index key storage area for storing one or more key items in an index storage area, an aggregation operation result storage area for storing an operation result of an arbitrary aggregation operation specified by a user, and a storage location of data in a corresponding database And a control information storage area for storing pointers to previous and next index entries, and these storage areas are grouped to form one index entry.

【0009】また、リレーショナルデータベース管理シ
ステム(RDBMS)は前記格納方法に従うインデクス
の定義手段として、利用者が前記インデクスキー格納領
域に格納するキー項目と、前記集約演算格納領域に格納
する集約演算を指定するインデクス定義手段を備えてい
る。
[0009] The relational database management system (RDBMS) may specify a key item to be stored in the index key storage area and an aggregation operation to be stored in the aggregation operation storage area as a means for defining an index according to the storage method. Index definition means to perform indexing.

【0010】さらに、RDBMSは集約演算を含む検索
処理のデータベース検索方法として、前記インデクスの
利用可否を判断し、利用可能ならば前記集約演算結果格
納領域の集約演算結果を利用するアクセス手順を生成す
る手段と、そのアクセス手順にしたがって記憶装置にア
クセスし、集約演算結果格納領域から集約演算結果を取
得するデータベース検索手段を備えている。
Further, the RDBMS determines whether or not the index can be used and generates an access procedure using the aggregated operation result in the aggregated operation result storage area if the index can be used, as a database search method for search processing including an aggregate operation. Means and a database search means for accessing the storage device in accordance with the access procedure and acquiring the aggregation operation result from the aggregation operation result storage area.

【0011】さらに、本発明に従うRDBMSは前記イ
ンデクスを定義したデータベースの更新方法として、前
記インデクスに保持した集約演算結果を常にデータベー
スの本体と矛盾のない状態で維持するため、データベー
スの更新に応じて前記インデクスのインデクスキー格納
領域と集約演算結果格納領域と制御情報格納領域とを更
新する内部処理手順を作る即ち、アクセス手順を生成す
る手段と、そのアクセス手順にしたがって記憶装置にア
クセスし、データベースと前記インデクスの各領域の内
容を更新するデータベース更新手段を備えている。
Further, in the RDBMS according to the present invention, as a method for updating the database defining the index, the RDBMS always maintains the aggregation operation results held in the index in a state consistent with the main body of the database. Creating an internal processing procedure for updating the index key storage area, the aggregation operation result storage area, and the control information storage area of the index, that is, means for generating an access procedure, accessing a storage device according to the access procedure, and A database updating means for updating the contents of each area of the index is provided.

【0012】以下、本発明の一実施例について図面に基
づいて詳細に説明する。図1は本発明によるデータベー
スシステムの構成例である。1は処理装置であり、デー
タベース管理システム11、インデクスを定義するユー
ザプログラム12、業務アプリケーションプログラム1
3がある。2はデータベース等を格納した外部記憶装置
であり、データベース21が格納してある。売上DBが
例として挙げてあるが、例えば人事のDBなどでも良く
データの種類は問わない。3はインデクス等を格納した
外部記憶装置であり、データベース21に対応するイン
デクス31が格納してある。311はインデクス31の
1つのインデクスエントリであり、インデクスキー格納
領域、集約演算結果格納領域、制御情報格納領域から構
成される。外部記憶装置3に格納してあるインデクス3
1は、外部記憶装置2に格納していてもよい。
An embodiment of the present invention will be described below in detail with reference to the drawings. FIG. 1 is a configuration example of a database system according to the present invention. Reference numeral 1 denotes a processing device, which is a database management system 11, a user program 12 for defining an index, and a business application program 1.
There are three. An external storage device 2 stores a database and the like, and stores a database 21. Although the sales DB is mentioned as an example, for example, a human resources DB may be used, and the type of data does not matter. Reference numeral 3 denotes an external storage device that stores indexes and the like, and stores an index 31 corresponding to the database 21. Reference numeral 311 denotes one index entry of the index 31, which includes an index key storage area, an aggregation operation result storage area, and a control information storage area. Index 3 stored in external storage device 3
1 may be stored in the external storage device 2.

【0013】図2はデータベース管理システム11の内
部コンポーネントの構成例である。各コンポーネントの
詳細はそれぞれ後述される。データベース管理システム
11は、本発明によるインデクスを定義する定義手段1
11と、データベース検索処理および更新処理において
アクセス手順を生成する手段112と、検索処理に対す
るアクセス手順にしたがって、外部記憶装置に格納され
たインデクスやデータベースにアクセスするデータベー
ス検索手段113と、更新処理に対するアクセス手順に
したがって、データベースとインデクスを更新するデー
タベース更新手段114とを備える。
FIG. 2 shows an example of the configuration of internal components of the database management system 11. Details of each component will be described later. The database management system 11 includes a definition unit 1 for defining an index according to the present invention.
11, a means 112 for generating an access procedure in a database search process and an update process, a database search means 113 for accessing an index or a database stored in an external storage device in accordance with the access procedure for the search process, and an access for the update process. A database updating unit 114 for updating a database and an index according to a procedure is provided.

【0014】図3は本発明によるインデクス〈インデク
スファイルともいう〉の構成例である。一般的にインデ
クスはバランス木構造をしており、根となるルートペー
ジを起点に複数階層の中間ページを経て、インデクスキ
ー値やそのキー値をもつデータへのアドレスなどを保持
するリーフページへ到達する構成をとる(図3
(a))。ルートページ、ノードと呼ばれる中間ページ
はリーフページを検索するためのものである。
FIG. 3 shows a configuration example of an index (also referred to as an index file) according to the present invention. In general, the index has a balanced tree structure, starting from the root page that is the root, passing through multiple intermediate pages, and arriving at the leaf page that holds the index key value and the address of the data with that key value, etc. (Figure 3
(A)). An intermediate page called a root page or a node is for searching for a leaf page.

【0015】リーフページではインデクスキー値ごとに
一つのインデクスエントリを構成し、各インデクスエン
トリ間はインデクスエントリを持っているページを順に
たどるためインデクスエントリに付されたポインタで相
互接続される。
In the leaf page, one index entry is formed for each index key value, and the index entries are interconnected by a pointer attached to the index entry in order to sequentially follow the page having the index entry.

【0016】図3(b)は、本発明の一実施例における
インデクスエントリの構成であり、複数のインデクスキ
ー項目312、利用者が指定した複数の集約演算結果3
13、キー値に対応するデータベースのデータ格納位置
を示す行識別子314、前後のインデクスエントリを示
すポインタ315で構成されている。
FIG. 3B shows a configuration of an index entry according to an embodiment of the present invention, in which a plurality of index key items 312 and a plurality of aggregation operation results 3 specified by the user are set.
13, a row identifier 314 indicating the data storage position of the database corresponding to the key value, and a pointer 315 indicating previous and next index entries.

【0017】図4はインデクス定義手段111によるイ
ンデクスの作成方法の一実施例をフローチャートで示し
たものである。まず、データベースをアクセスしてキー
項目の値を取得する(ステップ41)〈例えば、図8で
示した例では支店や商品分類の内容、即ち東京、大阪な
どである〉。そのキー値が新しく現れた値か既に現れた
値かを判断し(ステップ42)、新しく現れた値の場合
は、インデクスキー値格納領域に格納し(ステップ4
3)、集約演算結果格納領域に集約演算に応じた初期値
を格納する(ステップ44)。このとき集約演算の対象
がキー項目以外であれば、データベースをアクセスして
演算対象の項目の値を取得する。次に制御情報格納領域
に、1つ前のインデクスエントリのアドレスを格納し、
1つ前のインデクスエントリの制御情報格納領域に該イ
ンデクスエントリのアドレスを格納する(ステップ4
5)。キー項目の値が既出の場合は、同じ値のインデク
スエントリを検索し(ステップ48)、集約演算格納領
域の値を更新する(ステップ49)(例えば、合計を求
める集約演算であればそのエントリの値を加算する)。
このとき、集約対象がキー項目以外であれば、データベ
ースをアクセスして演算対象の項目の値を取得する。最
後にデータベースのデータ格納位置を示す行識別子を制
御情報格納領域に格納する(ステップ46)。以上の処
理をデータベース中の全てのデータに対して繰り返す
(ステップ47)。以上の処理により集約インデクスが
作成される。
FIG. 4 is a flowchart showing one embodiment of a method of creating an index by the index definition means 111. First, the value of the key item is acquired by accessing the database (step 41) (for example, in the example shown in FIG. 8, the contents of the branch and the product classification, that is, Tokyo, Osaka, etc.). It is determined whether the key value is a newly appearing value or a value that has already appeared (step 42). If the key value is a newly appearing value, it is stored in an index key value storage area (step 4).
3) The initial value corresponding to the aggregation operation is stored in the aggregation operation result storage area (step 44). At this time, if the target of the aggregation operation is other than the key item, the database is accessed to acquire the value of the item to be calculated. Next, the address of the previous index entry is stored in the control information storage area,
The address of the index entry is stored in the control information storage area of the previous index entry (step 4).
5). If the value of the key item has already been found, an index entry having the same value is searched (step 48), and the value of the aggregation operation storage area is updated (step 49). Value).
At this time, if the aggregation target is other than the key item, the database is accessed to acquire the value of the calculation target item. Finally, a row identifier indicating the data storage position of the database is stored in the control information storage area (step 46). The above processing is repeated for all data in the database (step 47). An aggregate index is created by the above processing.

【0018】図5は検索用アクセス手順生成手段の一実
施例をフローチャートで示したものである。一般にデー
タベースの1つの表には1または数本のインデクスが付
与されている。図5はその適切な1つを選び、適切なも
のが選択出来たならその参照を指示するフローチャート
である。以下の処理は検索する表が持つすべてのインデ
クスを対象に行なわれる。まず、ユーザにより定義され
たSQL文中にグループ化の指定があるか否かの判定を
行い(ステップ51)、グループ化指定がある場合〈例
えば、キー項目が、支店と商品分類である場合〉、検索
対象となるデータベースに定義されているインデクスの
キー項目とグループ化項目との一致の度合いを完全一致
〈例えば支店と商品分類〉、部分一致〈例えば支店また
は商品分類〉、不一致〈例えば、支店でも商品分類でも
ない〉に分けて評価する〈完全一致の場合が最も効率が
良く高く評価される〉。部分一致の場合は、合致してい
る項目数でさらに細分して評価し、インデクスの優先順
位を仮決定する(ステップ52)。グループ化の指定が
ない場合は、インデクス優先順位の仮決定はせず、探索
条件の評価を行なう。
FIG. 5 is a flowchart showing one embodiment of the search access procedure generating means. Generally, one or several indexes are assigned to one table of the database. FIG. 5 is a flowchart for selecting an appropriate one and instructing a reference when an appropriate one can be selected. The following processing is performed on all indexes of the table to be searched. First, it is determined whether or not there is a designation of grouping in the SQL statement defined by the user (step 51). If there is a designation of grouping (for example, if the key items are branch and product classification), Exact match (e.g., branch and product classification), partial match (e.g., branch or product classification), mismatch (e.g., even in branch) It is evaluated separately (not the product category) (exact match is the most efficient and highly evaluated). In the case of partial matching, the number of matching items is further subdivided and evaluated, and the priority order of the index is provisionally determined (step 52). If no grouping is specified, the search condition is evaluated without tentatively determining the index priority.

【0019】次に、SQL文中に探索条件、ソート項
目、集約演算が指定されているか否かの判定を行い(ス
テップ53)、指定がある場合、探索条件中の項目とデ
ータベースに定義されている各インデクスのキー項目や
ソート項目との一致の度合いをグループ化項目の場合と
同様の方法で評価し、また、=条件や範囲条件といった
探索条件の条件種別を評価し、先に仮決定したインデク
スの優先順位を再設定して(更に先頭のキー項目が対象
データを絞り込むものであるほど評価は高い)(ステッ
プ54)、最も優先順位の高いインデクスを選択する
(ステップ55)。
Next, it is determined whether or not a search condition, a sort item, and an aggregation operation are specified in the SQL statement (step 53). If specified, the item in the search condition and the definition in the database are defined. The degree of matching with the key item and sort item of each index is evaluated in the same way as for grouping items, and the condition types of search conditions such as = conditions and range conditions are evaluated, and the index temporarily determined earlier (Step 54), and the index with the highest priority is selected (step 55).

【0020】次に選択したインデクスが集約インデクス
かどうかを判断し(ステップ56)、集約インデクスの
場合は、集約演算の取得方法として、インデクスの集約
演算結果格納領域を参照する指示をする(ステップ5
7)。選択したインデクスが集約インデクスでない場合
は、集約演算の取得方法として集約対象項目の検索を指
示し、集約演算の実行を指示する(ステップ58)。探
索条件、ソート項目、集約演算の指定がない場合は、イ
ンデクスを使用せず、データベースを直接アクセスする
指示をする(ステップ59)。
Next, it is determined whether or not the selected index is an aggregated index (step 56). If the selected index is an aggregated index, an instruction to refer to the aggregated operation result storage area of the index is issued as a method of acquiring the aggregated operation (step 5).
7). If the selected index is not an aggregation index, a search for an aggregation target item is instructed as an acquisition method of an aggregation operation, and an execution of an aggregation operation is instructed (step 58). If no search condition, sort item, or aggregation operation is specified, an instruction is given to directly access the database without using the index (step 59).

【0021】図6は集約演算を含む検索処理に対するデ
ータベース検索方法の一実施例をフローチャートで示し
たものである。本実施例では、探索条件としてインデク
スのキー項目に対してBETWEEN述語と集約演算に
対する比較述語が指定されているものとする。最初に、
SQL文に指定された探索条件のうち、インデクスのキ
ー項目に対する条件でインデクスの参照範囲を限定す
る。すなわち、インデクスの階層構造を辿り、参照範囲
の開始となるインデクスキー値をもつインデクスエント
リと、参照範囲の終了となるインデクスエントリを取得
し、参照の開始となるインデクスエントリを処理対象と
して位置づける(ステップ61)。次に、開始インデク
スエントリの集約演算結果格納領域から探索条件に指定
した集約演算と合致する集約演算の結果を取得し(ステ
ップ62)、その値で探索条件を満たすか判定する(ス
テップ63)。条件を満たす場合は、検索項目に応じて
検索結果を返却する。このとき、インデクスエントリに
検索項目がすべて含まれるかを判定し(ステップ6
4)、すべての検索項目がインデクスエントリに含まれ
る場合は、インデクスエントリに格納した値を検索結果
として返却する(ステップ65)。インデクスエントリ
に含まれない検索項目が存在する場合は、制御情報格納
領域の行識別子から目的のデータベースを参照して検索
項目を取得し、検索結果として返却する(ステップ6
8)。検索結果を返却後、または、探索条件を満たさな
い場合は、該インデクスエントリの制御情報格納領域に
格納してある次インデクスエントリのポインタを辿り、
次のインデクスエントリへ移動する(ステップ66)。
以上の処理を参照範囲の終了インデクスエントリまで繰
り返す(ステップ67)。
FIG. 6 is a flowchart showing one embodiment of a database search method for search processing including an aggregation operation. In the present embodiment, it is assumed that a BETWEEN predicate and a comparison predicate for an aggregation operation are specified for a key item of an index as a search condition. At first,
Among the search conditions specified in the SQL statement, the reference range of the index is limited by the condition for the key item of the index. That is, by tracing the hierarchical structure of the index, an index entry having an index key value that starts the reference range and an index entry that ends the reference range are obtained, and the index entry that starts the reference is positioned as a processing target (step 61). Next, the result of the aggregation operation that matches the aggregation operation specified in the search condition is acquired from the aggregation operation result storage area of the start index entry (step 62), and it is determined whether the value satisfies the search condition (step 63). If the condition is satisfied, return the search result according to the search item. At this time, it is determined whether or not all the search items are included in the index entry (step 6).
4) If all search items are included in the index entry, the value stored in the index entry is returned as a search result (step 65). If there is a search item that is not included in the index entry, the search item is obtained by referring to the target database from the row identifier of the control information storage area, and returned as a search result (step 6).
8). After returning the search result or when the search condition is not satisfied, follow the pointer of the next index entry stored in the control information storage area of the index entry,
Move to the next index entry (step 66).
The above processing is repeated up to the end index entry of the reference range (step 67).

【0022】図7は更新用アクセス手順生成手段におけ
るインデクス更新判断方法の一実施例をフローチャート
で示したものである。まず、更新対象データベースに定
義されている全インデクスを抽出する(ステップ7
1)。次に、1つのインデクスを対象にして、更新する
項目がインデクスキー項目を含むか否か判定し(ステッ
プ72)、含む場合はインデクスキー項目の更新指示を
行い(ステップ75)、引き続きインデクス中の集約演
算を再計算しその結果への更新を指示する(ステップ7
6)。更新する項目がインデクスキー項目を含まない場
合は、更新する項目がインデクスの集約演算対象項目と
合致するかを調べ(ステップ73)、合致する場合はイ
ンデクスの集約演算を再計算しその結果への更新を指示
する(ステップ76)。以上の処理を該データベースに
定義されている全てのインデクスについて繰り返し行う
(ステップ74)。
FIG. 7 is a flowchart showing one embodiment of the index update determining method in the update access procedure generating means. First, all indexes defined in the update target database are extracted (step 7).
1). Next, for one index, it is determined whether or not the item to be updated includes an index key item (step 72). If so, an instruction to update the index key item is issued (step 75). Recalculate the aggregation operation and instruct to update the result (step 7)
6). If the item to be updated does not include the index key item, it is checked whether the item to be updated matches the item to be subjected to the aggregation operation of the index (step 73). If the item to be updated is determined, the aggregation operation of the index is recalculated and the result is calculated. Update is instructed (step 76). The above processing is repeated for all the indexes defined in the database (step 74).

【0023】図8はデータベースと集約インデクスとの
データの格納状態を示す図である。売り上げデータベー
スは、支店、商品分類、商品番号、売上金額の各項目で
構成し、実施例として各項目には図8(a)に示す値が
格納されているものとする。図8(b)は、売り上げデ
ータベースに対する集約インデクスであり、キー項目と
して支店と商品分類を指定し、集約演算として集約演算
COUNT(*)、集約演算SUM(売上金額)を指定
した場合のインデクスの状態を示している。
FIG. 8 is a diagram showing a data storage state of the database and the aggregate index. The sales database is composed of items such as a branch, a product classification, a product number, and a sales amount. As an example, it is assumed that each item stores a value shown in FIG. FIG. 8B shows an aggregate index for the sales database, in which a branch and a product classification are designated as key items, and an aggregate operation COUNT (*) and an aggregate operation SUM (sales amount) are designated as aggregate operations. The state is shown.

【0024】ここで、支店、商品分類が前述のグループ
化されたキー項目である。また、集合演算結果のSUM
は図7で述べたようにデータベースのデータでの売上金
額が更新されれば再計算されて更新される。制御情報
〈行識別子〉はデータベースへのポインタの働きをする
ものである。この集約インデクスは日次計算、月次計算
などの定型業務に有効である。
Here, the branch and the merchandise classification are the key items grouped as described above. Also, the SUM of the set operation result
Is recalculated and updated when the sales amount in the data of the database is updated as described in FIG. The control information <row identifier> serves as a pointer to the database. This aggregate index is effective for routine tasks such as daily calculation and monthly calculation.

【0025】インデクスの有無は別に設けられているデ
ィクショナリで定義されている。本インデクスを定義す
るSQL文の例を図10(a)に示す。
The presence or absence of an index is defined in a separately provided dictionary. FIG. 10A shows an example of an SQL statement that defines this index.

【0026】図9は業務適用例の処理の流れを示すフロ
ーチャートである。最初に、検索処理か更新処理かの判
定を行う(ステップ81)。本実施例の業務アプリケー
ションプログラムの検索処理は、支店と商品分類でグル
ープ化し、グループごとの売り上げ件数、合計売り上げ
金額を集計する処理であり、図10(b)に示すSQL
を発行する。SQLが入力されると、アクセス手順生成
手段112により、図5に示した方法で適切なインデク
スを利用したアクセス手順が生成され(ステップ8
3)、データベース検索手段113により、前記アクセ
ス手順にしたがって検索結果を取得する(ステップ8
4)。一方、更新処理では、図10(e)に示すSQL
を発行する。更新SQLが入力されると、アクセス手順
生成手段112により、図7の方法で更新する項目に応
じてインデクスを適切に更新するアクセス手順を生成し
(ステップ86)、図7で示されるデータベース更新手
段114により、データベースおよびインデクスの更新
処理を実行する(ステップ87)。
FIG. 9 is a flowchart showing the flow of processing in a business application example. First, it is determined whether the process is a search process or an update process (step 81). The search process of the business application program according to the present embodiment is a process of grouping by branch and product classification, and totaling the number of sales and the total sales amount for each group. The SQL shown in FIG.
Issue When the SQL is input, the access procedure generation means 112 generates an access procedure using an appropriate index by the method shown in FIG. 5 (step 8).
3) The database search means 113 obtains a search result according to the access procedure (step 8).
4). On the other hand, in the update process, the SQL shown in FIG.
Issue When the update SQL is input, the access procedure generating means 112 generates an access procedure for appropriately updating the index according to the item to be updated by the method of FIG. 7 (step 86), and the database updating means shown in FIG. According to 114, the database and the index are updated (step 87).

【0027】本例で用いた図10(b)の検索SQLで
は、SQLのグループ化項目とインデクスキー項目が一
致し、かつ選択項目に指定した集約演算とインデクスに
定義した集約演算とが一致しているため、、図8(b)
に示すインデクスのみにアクセスし、集約演算結果を参
照することでSQLの検索結果を得ることができる。す
なわち、データベースへのアクセスや集約演算処理は不
要である。
In the search SQL of FIG. 10B used in this example, the grouping item of the SQL matches the index key item, and the aggregation operation specified in the selection item matches the aggregation operation defined in the index. FIG. 8 (b)
By accessing only the index shown in (1) and referring to the aggregation operation result, an SQL search result can be obtained. That is, access to the database and aggregation processing are not required.

【0028】集約演算を含む図10(b)のSQLが入
力された場合、従来技術では集約演算COUNT(*)
は、インデクスのみから演算可能であるが、集約演算S
UM(売上金額)については、元となる売り上げデータ
ベースにアクセスしなければ演算できず、入出力オーバ
ヘッドが発生していた。また、両集約演算とも検索処理
実行時に演算をしなければならず、演算オーバヘッドも
生じていた。これに対して、本発明による集約インデク
スを利用した場合、両集約演算とも演算結果をインデク
ス中に保持しているため、インデクスのみのアクセスで
かつ演算処理を行わずに検索結果を取得することがで
き、入出力および演算オーバヘッドを抑止して応答性能
を向上することができる。
When the SQL of FIG. 10B including the aggregation operation is input, the aggregation operation COUNT (*) is used in the prior art.
Can be operated only from the index, but the aggregate operation S
The UM (sales amount) cannot be calculated unless the original sales database is accessed, resulting in input / output overhead. In addition, both aggregation operations have to be performed at the time of execution of the search processing, and there has been an operation overhead. On the other hand, when the aggregate index according to the present invention is used, since both aggregate operations hold the operation result in the index, it is possible to obtain the search result by accessing only the index and without performing the operation process. Thus, the input / output and operation overhead can be suppressed, and the response performance can be improved.

【0029】従来技術の方法では図10(b)のSQL
文の実行時間は、インデクスおよびデータベースの入力
時間と集約演算の処理時間の合計となる。これに対し
て、本発明を適用した場合の実行時間はインデクスの入
力時間だけとなる。集約インデクスは従来のインデクス
よりも容量が大きくなるためインデクスの入力時間だけ
で比較すると従来のインデクス入力時間よりも長くなる
が、データベースの入力時間に比べれば十分小さく、し
たがってSQL文の実行時間を削減することが出来る。
In the method of the prior art, the SQL shown in FIG.
The execution time of the statement is the sum of the input time of the index and the database and the processing time of the aggregation operation. On the other hand, the execution time when the present invention is applied is only the index input time. Aggregated indexes have a larger capacity than conventional indexes, so when compared by index input time alone, they are longer than conventional index input times, but are sufficiently smaller than database input times, thus reducing SQL statement execution time. You can do it.

【0030】別の検索パタン例として、図10(c)に
示すSQLのように、探索条件として集約演算が指定さ
れた場合でも、インデクスに保持している集約演算結果
を参照して条件評価を行うことで検索結果を得ることが
でき、この場合もデータベースへの入出力、検索実行時
の演算処理とも不要である。さらに別の検索パタン例と
して図10(d)に示すSQLのように、グループ化項
目がインデクスキー項目より少ない場合では、インデク
スに保持した集約演算結果をそのまま利用することはで
きない。しかしながら、インデクスに保持した集約演算
結果をもとにして集約演算を行うことで結果を得ること
ができ、集約演算にかかる演算オーバヘッドを従来技術
に比べて減少させることができる。
As another example of a search pattern, even when an aggregation operation is specified as a search condition, as in SQL shown in FIG. 10C, the condition evaluation is performed with reference to the aggregation operation result held in the index. By doing so, a search result can be obtained. In this case, neither input / output to the database nor arithmetic processing at the time of executing the search is necessary. As another search pattern example, when the number of grouping items is smaller than the number of index key items, as in SQL shown in FIG. 10D, the aggregation operation result held in the index cannot be used as it is. However, the result can be obtained by performing the aggregation operation based on the aggregation operation result held in the index, and the operation overhead related to the aggregation operation can be reduced as compared with the related art.

【0031】[0031]

【発明の効果】本発明によれば、リレーショナルデータ
ベースの集約演算を含む検索処理において、集約演算を
行うための入出力オーバヘッドや演算オーバヘッドを抑
止することができ、応答性能を向上する効果がある。
According to the present invention, in a search process including an aggregation operation of a relational database, an input / output overhead and an operation overhead for performing the aggregation operation can be suppressed, and the response performance is improved.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明の一実施例を示す説明図である。FIG. 1 is an explanatory diagram showing one embodiment of the present invention.

【図2】データベース管理システムの構成を示す説明図
である。
FIG. 2 is an explanatory diagram showing a configuration of a database management system.

【図3】本発明によるインデクスの構成を示す説明図で
ある。
FIG. 3 is an explanatory diagram showing a configuration of an index according to the present invention.

【図4】本発明によるインデクスの作成方法を示すフロ
ーチャートである。
FIG. 4 is a flowchart illustrating an index creation method according to the present invention.

【図5】検索処理におけるアクセス手順生成方法を示す
フローチャートである。
FIG. 5 is a flowchart illustrating an access procedure generation method in a search process.

【図6】データベース検索方法を示すフローチャートで
ある。
FIG. 6 is a flowchart illustrating a database search method.

【図7】更新処理におけるアクセス手順生成方法を示す
フローチャートである。
FIG. 7 is a flowchart illustrating an access procedure generation method in an update process.

【図8】業務適用例で用いる売り上げデータベースとイ
ンデクスの構成を示した説明図である。
FIG. 8 is an explanatory diagram showing a configuration of a sales database and an index used in a business application example.

【図9】業務適用例で用いる業務アプリケーションプロ
グラムの処理を示すフローチャートである。
FIG. 9 is a flowchart illustrating processing of a business application program used in a business application example.

【図10】業務適用例で用いるSQL文の例である。FIG. 10 is an example of an SQL statement used in a business application example.

【符号の説明】[Explanation of symbols]

1:処理装置 2:データベースを格納する外部記憶装置 3:インデクスを格納する外部記憶装置 11:データベース管理システム 12:インデクス定義用ユーザプログラム 13:業務アプリケーションプログラム 21:データベース 31:データベース21に対するインデクス 311:インデクスエントリの格納領域 1: Processing device 2: External storage device for storing a database 3: External storage device for storing an index 11: Database management system 12: User program for index definition 13: Business application program 21: Database 31: Index for the database 21 31: Index entry storage area

Claims (10)

【特許請求の範囲】[Claims] 【請求項1】リレーショナルデータベースにおいて、利
用者によって指定され作成された集約演算結果をインデ
クス内に格納し、集約演算を含む検索処理において前記
インデクスに格納された演算結果を参照することを特徴
とする集約演算処理方法。
In a relational database, an aggregation operation result designated and created by a user is stored in an index, and the operation result stored in the index is referred to in a search process including an aggregation operation. Aggregation operation processing method.
【請求項2】リレーショナルデータベースにおいて、イ
ンデクス内にキー項目と、集約演算結果と、キー項目に
対応するデータベース内の行識別子とを有するインデク
スエントリを形成し、集約演算を含む検索が行なわれる
場合に、前記集約演算結果が利用可のとき前記集約演算
結果を使用することを特徴とする集約演算処理方法。
2. In a relational database, when an index entry having a key item, an aggregation operation result, and a row identifier in the database corresponding to the key item is formed in an index, and a search including an aggregation operation is performed, An aggregation operation processing method, wherein the aggregation operation result is used when the aggregation operation result is available.
【請求項3】リレーショナルデータベースにおいて、1
または複数のインデクスにキー項目をグループ化項目と
する集約演算結果を格納し、キー項目と検索に指定され
たグループ化項目との一致度が高いインデクスを選択
し、選択されたインデクスが集約演算結果を含むインデ
クスの場合、当該インデクスの集約演算結果を参照する
よう指示することを特徴とする集約演算処理方法。
3. In a relational database, 1
Alternatively, store the aggregation operation results with key items as grouping items in multiple indexes, select an index that has a high degree of matching between the key items and the grouping items specified in the search, and select the selected index as the aggregation operation result In the case of an index including (1), an instruction is issued to refer to the result of the aggregation operation of the index.
【請求項4】リレーショナルデータベースにおいて、1
または複数のインデクスに集約演算結果を格納し、キー
項目が検索条件との一致度が高く、かつ検索結果をより
絞り込むキー項目が先頭にあるインデクスを優先して選
択し、選択されたインデクスが集約演算結果を含むイン
デクスの場合、当該インデクスの集約演算結果を参照す
るよう指示することを特徴とする集約演算処理方法。
4. In a relational database, 1
Alternatively, store the aggregation operation results in multiple indexes, select the index with the key item that has a high degree of matching with the search condition and the key item that further narrows the search results at the head, and aggregate the selected indexes In the case of an index including an operation result, an aggregation operation processing method is provided, wherein an instruction is issued to refer to the aggregation operation result of the index.
【請求項5】リレーショナルデータベースにおいて、イ
ンデクス内にキー項目と、集約演算結果と、キー項目に
対応するデータベース内の行識別子と前後のインデクス
エントリを示すポインタとを有するインデクスエントリ
を形成し、前記インデクスエントリを前記ポインタで辿
り、集約演算結果が探索条件を満たすとき検索項目に応
じて前記インデクスエントリに格納されている値を返却
して次のインデクスエントリに移動し、集約演算結果が
探索条件を満たさないときはそのまま次のインデクスエ
ントリに移動することを特徴とする集約演算処理方法。
5. In a relational database, an index entry having a key item, an aggregation operation result, a row identifier in the database corresponding to the key item, and pointers indicating previous and next index entries is formed in the index, and The entry is traced by the pointer, and when the aggregation operation result satisfies the search condition, the value stored in the index entry is returned according to the search item and moved to the next index entry, and the aggregation operation result satisfies the search condition. An aggregation processing method characterized by moving to the next index entry when there is no such entry.
【請求項6】リレーショナルデータベースにおいて、利
用者によって指定され作成された集約演算結果をインデ
クス内に格納し、データベースの更新があると、そのデ
ータベースに関する全インデクスを抽出し、更新する項
目がインデクスの集約演算対象項目と合致した場合、イ
ンデクスの集約演算を再計算してその結果への更新指示
を行なうことを前記全インデクスについて繰り返し行な
うことを特徴とする集約演算処理方法。
6. In a relational database, an aggregation operation result specified and created by a user is stored in an index, and when a database is updated, all indexes related to the database are extracted, and the items to be updated are aggregated indexes. An aggregation operation processing method, characterized in that, when a match is found with an operation target item, recalculation of an index aggregation operation and instructing an update to the result are repeatedly performed for all the indexes.
【請求項7】リレーショナルデータベースにおいて、利
用者によって指定され作成された集約演算結果を格納し
たインデクスと、集約演算を含む検索処理において前記
インデクスに格納された演算結果を参照する手段とを有
することを特徴とする集約演算処理装置。
7. A relational database, comprising: an index storing an aggregate operation result designated and created by a user; and means for referring to the operation result stored in the index in a search process including an aggregate operation. Aggregate arithmetic processing device.
【請求項8】リレーショナルデータベースにおいて、1
または複数のインデクスに集約演算結果が格納されてお
り、キー項目が最も検索に適したインデクスを選択する
手段と、選択されたインデクスが集約演算結果を含むイ
ンデクスの場合、当該インデクスの集約演算結果を参照
するよう指示する手段とを備えたことを特徴とする集約
演算処理装置。
8. In a relational database, 1
Alternatively, the aggregation operation result is stored in multiple indexes, and the key item selects the index that is most suitable for the search.If the selected index is an index that includes the aggregation operation result, the aggregation operation result of the index is Means for instructing to refer to.
【請求項9】1または複数のキー項目を格納するインデ
クスキー格納領域と、利用者が指定した集約演算の演算
結果を格納する集約演算結果格納領域と、データベース
中のデータの格納位置を示すポインタを格納する制御情
報格納領域とを備えたリレーショナルデータベースにお
けるインデクス。
9. An index key storage area for storing one or more key items, an aggregation operation result storage area for storing an operation result of an aggregation operation specified by a user, and a pointer indicating a storage position of data in a database. An index in a relational database including a control information storage area for storing the information.
【請求項10】リレーショナルデータベースにおけるプ
ログラムであって、利用者によって指定され作成された
集約演算結果をインデクス内に格納し、集約演算を含む
検索処理において前記インデクスに格納された演算結果
を参照することを特徴とする集約演算処理プログラムを
記録したコンピュータ読み取り可能な記録媒体。
10. A program in a relational database, wherein an aggregation operation result designated and created by a user is stored in an index, and the operation result stored in the index is referred to in a search process including the aggregation operation. A computer-readable recording medium having recorded thereon an aggregation processing program.
JP33694199A 1999-11-29 1999-11-29 Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program Pending JP2001155028A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP33694199A JP2001155028A (en) 1999-11-29 1999-11-29 Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP33694199A JP2001155028A (en) 1999-11-29 1999-11-29 Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program

Publications (1)

Publication Number Publication Date
JP2001155028A true JP2001155028A (en) 2001-06-08

Family

ID=18304051

Family Applications (1)

Application Number Title Priority Date Filing Date
JP33694199A Pending JP2001155028A (en) 1999-11-29 1999-11-29 Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program

Country Status (1)

Country Link
JP (1) JP2001155028A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010262455A (en) * 2009-05-01 2010-11-18 Brother Ind Ltd Management apparatus, information generation program, and information generation method
WO2022049680A1 (en) * 2020-09-02 2022-03-10 日本電気株式会社 Coupling table specification system, coupling table search device, method, and program

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08329101A (en) * 1995-05-30 1996-12-13 Fujitsu Ltd Data base system
JPH09265479A (en) * 1996-03-29 1997-10-07 Hitachi Ltd Multi-dimensional data processing method
JPH1078968A (en) * 1996-09-02 1998-03-24 Nippon Telegr & Teleph Corp <Ntt> Statistic data base system
JPH1097544A (en) * 1996-09-20 1998-04-14 Hitachi Ltd Database processing system
JPH10340276A (en) * 1997-04-09 1998-12-22 Ibm Japan Ltd Intensive operation executing method, and computer system therefor
JPH113354A (en) * 1997-06-13 1999-01-06 Nec Software Ltd Data cube control system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH08329101A (en) * 1995-05-30 1996-12-13 Fujitsu Ltd Data base system
JPH09265479A (en) * 1996-03-29 1997-10-07 Hitachi Ltd Multi-dimensional data processing method
JPH1078968A (en) * 1996-09-02 1998-03-24 Nippon Telegr & Teleph Corp <Ntt> Statistic data base system
JPH1097544A (en) * 1996-09-20 1998-04-14 Hitachi Ltd Database processing system
JPH10340276A (en) * 1997-04-09 1998-12-22 Ibm Japan Ltd Intensive operation executing method, and computer system therefor
JPH113354A (en) * 1997-06-13 1999-01-06 Nec Software Ltd Data cube control system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2010262455A (en) * 2009-05-01 2010-11-18 Brother Ind Ltd Management apparatus, information generation program, and information generation method
WO2022049680A1 (en) * 2020-09-02 2022-03-10 日本電気株式会社 Coupling table specification system, coupling table search device, method, and program
JP7424501B2 (en) 2020-09-02 2024-01-30 日本電気株式会社 Joined table identification system, joined table search device, method and program

Similar Documents

Publication Publication Date Title
JP2831856B2 (en) Database access method
US6009432A (en) Value-instance-connectivity computer-implemented database
US6185557B1 (en) Merge join process
US6484181B2 (en) Method and system for handling foreign key update in an object-oriented database environment
US7240044B2 (en) Query optimization by sub-plan memoization
EP0877327B1 (en) Method and apparatus for performing a join query in a database system
US6925462B2 (en) Database management system, and query method and query execution program in the database management system
US7734620B2 (en) Optimizing a database query that fetches N rows
JP3742177B2 (en) Parallel database system routine execution method
US6675160B2 (en) Database processing method, apparatus for carrying out the same and medium storing processing program
US20070294050A1 (en) Apparatus and method for monitoring usage of components in a database index
US6122644A (en) System for halloween protection in a database system
US6260037B1 (en) Method and computer program product for implementing skip key processing for database grouping queries involving aggregate operations by using one or more indices
JP2001155028A (en) Aggregate calculation processing method and device for relational database, and computer readable recording medium recorded with aggregate arithmetic processing program
JPH06215037A (en) Automatic updating device for index
CN109241098B (en) Query optimization method for distributed database
KR100333682B1 (en) A Query Processing Method For Grouping And Aggregation Operations In Object-Relational Database Systems Using Reverse Pointers
US20060235819A1 (en) Apparatus and method for reducing data returned for a database query using select list processing
JP2000250921A (en) Method and system for managing database
JPH10269225A (en) Data base dividing method
Dombrovskaya et al. Even More Theory: Algorithms
JPH02190970A (en) Index structure and search processing method using the structure
Goldstein et al. Database management with sequence trees and tokens
JPH11242627A (en) Data access method and medium recording program
JPH04156624A (en) High speed accessing systme in knowledge base systme

Legal Events

Date Code Title Description
A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050125

A02 Decision of refusal

Free format text: JAPANESE INTERMEDIATE CODE: A02

Effective date: 20050712