JPH05165894A - Binary search method of data base - Google Patents

Binary search method of data base

Info

Publication number
JPH05165894A
JPH05165894A JP3327622A JP32762291A JPH05165894A JP H05165894 A JPH05165894 A JP H05165894A JP 3327622 A JP3327622 A JP 3327622A JP 32762291 A JP32762291 A JP 32762291A JP H05165894 A JPH05165894 A JP H05165894A
Authority
JP
Japan
Prior art keywords
key
search
comparison
frequency
binary
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
JP3327622A
Other languages
Japanese (ja)
Inventor
Shuichi Matsumoto
秀一 松本
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 Software Engineering Co Ltd
Hitachi Ltd
Original Assignee
Hitachi Software Engineering Co Ltd
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 Software Engineering Co Ltd, Hitachi Ltd filed Critical Hitachi Software Engineering Co Ltd
Priority to JP3327622A priority Critical patent/JPH05165894A/en
Publication of JPH05165894A publication Critical patent/JPH05165894A/en
Pending legal-status Critical Current

Links

Landscapes

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

Abstract

PURPOSE:To reduce the average number of times of comparison of a key in a binary search method. CONSTITUTION:Before a binary search is executed, the search frequency of each key value 41, 42... stored in each entry of search tables 31, 32... within nodes 12, 13... is investigated. If the key value whose search frequency is higher than the preliminarily fixed threshold exists, an entry position storing the key value having the highest frequency of the key values is stored in a initial comparison key position storage area 2. At the time of executing a binary search, if the position of the key is stored in this initial comparison key position storage area 2, a comparison is not performed with the key of the center position of search tables 12, 13... and the comparison is performed with this initial comparison key as for the only first key comparison. Therefore, as the comparison of the first key value in the binary search is performed with the key value having the highest search frequency, the possibility of the success of a search by a comparison is high and the average number of times of comparison of the key value can be reduced.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【産業上の利用分野】本発明は、データベースの探索に
おいて、探索頻度に偏りがあり特定のキ−に探索が集中
する場合、キ−の比較回数を少なくして高速に探索を終
了するのに好適な2分探索方法に関するものである。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention is intended to quickly search a database by reducing the number of key comparisons when the search frequency is biased and the search concentrates on a specific key. The present invention relates to a suitable binary search method.

【0002】[0002]

【従来の技術】従来技術による2分探索方法は、デーイ
ー クヌース著 ジ アート オブコンピュータ プロ
グラミング ボリューム3 ソーティング アンド サ
ーチーング ページ406ー408 アディソン ウェ
スリー社 1975年発行(D.E.Knuth著 ”
The Art of ComputerProgra
mming Vol.3 Sorting and S
earching”,pp406−408,Addis
on−Wesley,(1975))に見られるよう
に、探索対象のキ−と探索表のキ−を比較するのに必ず
探索範囲の中央のキ−と比較するため、比較回数は探索
対象のキ−の探索表内の位置に依存し、キ−の値の分布
や、探索頻度を考慮したものではなかった。
2. Description of the Related Art A binary search method according to the prior art is described by D. Knuth, The Art of Computer Programming Volume 3, Sorting and Searching, pages 406-408, Addison Wesley, Inc., 1975 (by DE Knuth).
The Art of Computer Program
mming Vol. 3 Sorting and S
“Eaching”, pp406-408, Addis
on-Wesley, (1975)), the key of the search target and the key of the search table are always compared with the key in the center of the search range. The distribution of key values and the search frequency were not taken into consideration, depending on the position of the − in the search table.

【0003】これに対して、特開昭62−8226号公
報に開示された2文探索方法は、キ−の分布を一次方程
式で予測し、キ−の比較位置を探索範囲の中央の位置か
らずらすことによって比較回数を削減するものである。
しかし、この2文探索方法は、キ−の探索頻度を考慮し
ておらず、探索頻度の高いキ−の比較回数は必ずしも削
減できるとは限らない。
On the other hand, the two-sentence search method disclosed in Japanese Patent Laid-Open No. 62-8226 predicts the distribution of keys by a linear equation and determines the key comparison position from the center position of the search range. By shifting, the number of comparisons is reduced.
However, this two-sentence search method does not consider the key search frequency, and the number of comparisons of keys with a high search frequency cannot always be reduced.

【0004】この他に、探索頻度を考慮したデ−タ探索
方法として特開昭60−173628号公報、特開昭6
2−74128号公報、特開昭62−256442号公
報、及び特開昭62−296226号公報等に開示され
たものが存在するが、いずれも2分探索方法に適用でき
る探索方法ではない。
In addition to this, as a data search method in consideration of the search frequency, JP-A-60-173628 and JP-A-6-36628
There are those disclosed in JP-A 2-74128, JP-A-62-256442, JP-A-62-296226 and the like, but none of them is a search method applicable to the binary search method.

【0005】[0005]

【発明が解決しようとする課題】上記特開昭62−82
26号公報に開示されている2分探索方法は、探索頻度
が一様であるときに比較回数が最適になる方式である
が、探索頻度に偏りがある場合は、必ずしも最適になる
とはいえない。
DISCLOSURE OF THE INVENTION Problems to be Solved by the Invention JP-A-62-82
The binary search method disclosed in Japanese Patent No. 26 is a method in which the number of comparisons is optimized when the search frequency is uniform, but it cannot be said that it is always optimum when the search frequency is biased. ..

【0006】本発明は、上記した従来技術の問題点に鑑
み成されたもので、探索頻度の偏りに関する情報を利用
することにより平均比較回数を削減し、高速に探索を終
了する2分探索方法を提供することを目的としている。
The present invention has been made in view of the above-mentioned problems of the prior art, and uses the information on the deviation of the search frequency to reduce the average number of comparisons, and the binary search method for ending the search at high speed. Is intended to provide.

【0007】[0007]

【課題を解決するための手段】上記目的を達成するため
に、2分探索を実行する前に、探索表の中の各キ−の探
索頻度を調べ、探索頻度があらかじめ定めたしきい値よ
り高いものがあれば、その中で最も頻度の高いキ−の探
索表上の位置を記憶しておく。最も頻度の高いキ−の位
置が記憶されていた場合は、2分探索の実行時に、その
キ−と探索キ−を先ず比較することで、キ−の平均比較
回数を削減するものである。
In order to achieve the above-mentioned object, the search frequency of each key in the search table is checked before executing the binary search, and the search frequency is lower than a predetermined threshold value. If there is a high one, the position of the most frequent key on the search table is stored. When the position of the key with the highest frequency is stored, the average number of times of key comparison is reduced by first comparing the key and the search key when executing the binary search.

【0008】また、本発明をB木に適用する場合は、上
記2分探索法の方法を、B木のノ−ド毎に適用すること
で、B木の各ノ−ドにおける2分探索のキ−の平均比較
回数を削減するものである。
When the present invention is applied to a B-tree, the above-described binary search method is applied to each node of the B-tree so that the binary search in each node of the B-tree can be performed. This is to reduce the average number of key comparisons.

【0009】[0009]

【作用】本発明の2分探索方法では、2分探索を実行す
る前に、探索表の中の各キ−の探索頻度を調べ、探索頻
度があらかじめ定めたしきい値より高いものがあれば、
その中で最も頻度の高いキ−の探索表上の位置(エント
リ番号)を記憶しておく。ここで、あらかじめ定めたし
きい値とは、本発明の実施方法により異なるが、本発明
を実施したとき、従来の2分探索法に比べてキ−の平均
比較回数が十分少なくなるように定めるものである。
According to the binary search method of the present invention, the search frequency of each key in the search table is checked before executing the binary search, and if the search frequency is higher than a predetermined threshold value, ,
The position (entry number) of the key with the highest frequency among them is stored. Here, the predetermined threshold differs depending on the implementation method of the present invention, but when the present invention is implemented, it is determined so that the average number of key comparisons is sufficiently smaller than that of the conventional binary search method. It is a thing.

【0010】単独の探索表に対する2分探索は、次の手
順で行う。
The binary search for a single search table is performed in the following procedure.

【0011】(1)探索頻度がしきい値を越える最も頻
度の高いキ−の位置(エントリ番号)が探索表に記憶さ
れている場合は、2分探索法における初回のキ−の比較
は、探索表の中央の位置のキ−とではなく、この記憶さ
れているキ−と比較を行う。キ−の位置が記憶されてい
ない場合は、初回のキ−の比較は、探索表の中央の位置
のキ−と比較を行う。
(1) When the position (entry number) of the most frequent key whose search frequency exceeds the threshold value is stored in the search table, the first key comparison in the binary search method is The stored key is compared, not the key at the center of the look-up table. When the key position is not stored, the first key comparison is performed with the key at the center position of the search table.

【0012】(2)これ以降は、従来の一般的な2分探
索法と同じ手順で、上記比較の結果に従って、探索を終
了させるか、このキ−よりも大きいキ−の範囲かこのキ
−より小さいキ−の範囲のいずれかを次の探索範囲とし
て2分探索を続行するする。2分探索を続行する場合
は、次に比較するキ−の位置は、従来の一般的な2分探
索法と同じく、探索範囲の中央の位置のキ−とする。
(2) From this point onward, according to the result of the above comparison, the search is terminated or the range of a key larger than this key or this key is followed by the same procedure as the conventional general binary search method. The binary search is continued with any one of the smaller key ranges as the next search range. When the binary search is continued, the key position to be compared next is the key at the center position of the search range, as in the conventional general binary search method.

【0013】また、本発明をB木に適用する場合は、各
ノ−ドにおける2分探索は、次の手順で行う。
When the present invention is applied to the B-tree, the binary search in each node is performed according to the following procedure.

【0014】(1)探索頻度がしきい値を越える最も頻
度の高いキ−の位置(エントリ番号)が探索表に記憶さ
れている場合は、2分探索法における初回のキ−の比較
は、探索表の中央の位置のキ−とではなく、この記憶さ
れているキ−と比較を行う。キ−の位置が記憶されてい
ない場合は、初回のキ−の比較は、探索表の中央の位置
のキ−と比較を行う。
(1) When the position (entry number) of the most frequent key whose search frequency exceeds the threshold value is stored in the search table, the first key comparison in the binary search method is The stored key is compared, not the key at the center of the look-up table. When the key position is not stored, the first key comparison is performed with the key at the center position of the search table.

【0015】(2)キ−の位置が記憶されている場合
で、この比較の結果、このキ−に対応する下位のノ−ド
に探索が及ぶ可能性があるときは、必要に応じてこのキ
−と隣接するキ−の値を調べて、このキ−が探索の目的
のキ−かどうか確かめ、探索目的のキ−である場合は、
下位のノ−ドの探索に移る。
(2) If the position of the key is stored and the result of this comparison is that the search may reach the lower node corresponding to this key, this search is performed if necessary. Check the value of the key adjacent to the key to see if this key is the key for the search, and if it is the key for the search,
Move on to search for lower nodes.

【0016】(3)下位のノ−ドの探索に移る場合以外
は、従来の一般的な2分探索法と同じ手順で、上記
(1)の比較結果に従って、探索を終了させるか、この
キ−よりも大きいキ−の範囲かこのキ−より小さいキ−
の範囲のいずれかを次の探索範囲として2分探索を続行
するする。2分探索を続行する場合は、次に比較するキ
−の位置は、従来の一般的な2分探索法と同じく、探索
範囲の中央の位置のキ−とする。
(3) Except when moving to the search of lower nodes, the search is terminated or this key is executed according to the comparison result of (1) above by the same procedure as the conventional general binary search method. -Key range greater than or less than this key
The dichotomizing search is continued with any of the ranges of (2) as the next searching range. When the binary search is continued, the key position to be compared next is the key at the center position of the search range, as in the conventional general binary search method.

【0017】本発明の方式では、最初の比較を最も探索
頻度の高いキ−に対して行うため、単独の探索表に対す
る2分探索の場合で1回、B木の各ノ−ドの2分探索の
場合で1回又は2回の比較で探索が成功する可能性が高
い。この比較で不一致になったときは、このキ−より大
きい範囲又はこのキ−より小さい範囲のいずれかに、従
来の一般的な2分探索法と同じ手順を適用するので、従
来の2分探索法より、比較回数が場合によって高々1回
又は2回増えるだけである。このため、位置を記憶する
キ−の探索頻度が十分高ければ、平均比較回数が従来の
2分探索法より少なくなる。
In the method of the present invention, since the first comparison is performed for the key having the highest search frequency, it is once for the binary search for a single search table and for the binary search for each node of the B tree. In the case of search, there is a high possibility that the search will be successful if it is compared once or twice. If there is a mismatch in this comparison, the same procedure as the conventional general binary search method is applied to either the range larger than this key or the range smaller than this key. According to the law, the number of comparisons increases only once or twice depending on the case. Therefore, if the search frequency of the key for storing the position is sufficiently high, the average number of comparisons becomes smaller than that of the conventional binary search method.

【0018】[0018]

【実施例】次に、本発明をデータベースのインデックス
を構成するB木(Balancdtree)に適用する
場合の実施例を図面に基づいて説明する。図1は、デ−
タベ−スのインデクスをB木によって構成した場合のデ
−タベ−スの構造を表している。B木7において、
1,12,13…はノードを示し、ノード12,13…は
葉のノードである。各ノ−ド11,12,13…はノ−ド
間のリンク51,52,…によって互いに関連付けられ、
木構造を成している。葉のノード12,13…は、リンク
1,82…によってデ−タレコ−ド61,62…と関連付
けられている。また、各ノ−ド11,12,13…には、
2分割探索法を適用する探索表31,32,33…が設け
られており、探索表31,32,33…には各データレコ
ード61,62…に付された各キ−値41,42等を記憶す
る複数のエントリ域が設けられ、各エントリには図示す
るように、各データレコード61,62…に付されたキー
値41,42等が格納されている。また、各ノ−ド11
2,13…には、各ノード内で最も探索頻度の高いキ−
(データレコード)の値を格納しているエントリの番号
を記憶する初回比較キ−位置記憶域21,22,23…が
設けられている。ここで、各ノードの各エントリには、
上記ノード間のリンク51,52,…又は葉のノードとデ
ータレコード間のリンク81,82…が格納されている。
DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS Next, an embodiment in which the present invention is applied to a B-tree (Balanctree) forming an index of a database will be described with reference to the drawings. Figure 1 shows
The structure of the database when the index of the table is constructed by a B-tree is shown. In B-tree 7,
1 1 1 2 1 3 ... Show nodes, and nodes 1 2 1 3 ... Are leaf nodes. Each of the nodes 1 1 , 1 2 , 1 3 ... Is related to each other by links 5 1 , 5 2 ,.
It has a tree structure. The leaf nodes 1 2 , 1 3 ... Are associated with the data records 6 1 , 6 2 ... By links 8 1 , 8 2 . Also, in each node 1 1 , 1 2 , 1 3 ...
A search table 3 1 , 3 2 , 3 3 ... to which the two-division search method is applied is provided, and the search table 3 1 , 3 2 , 3 3 ... is attached to each data record 6 1 , 6 2 . A plurality of entry areas for storing each key value 4 1 , 4 2, etc. are provided, and each entry has a key value 4 1 , 4 2 attached to each data record 6 1 , 6 2, ... Etc. are stored. Also, each node 1 1 ,
The key with the highest search frequency in each node is 1 2 , 1 3 ...
First-comparison key position storage areas 2 1 , 2 2 , 2 3, ... For storing the number of the entry storing the value of (data record) are provided. Here, in each entry of each node,
The links 5 1 , 5 2, ... Between the nodes or the links 8 1 , 8 2, ... Between the leaf node and the data record are stored.

【0019】各ノ−ド11,12,13…の初回比較キ−
位置記憶域2には、2分探索を行う前に、次の手順で値
を設定しておく。
Initial comparison key for each node 1 1 , 1 2 , 1 3 ...
A value is set in the position storage area 2 by the following procedure before performing the binary search.

【0020】葉のノード(12,13…)の場合 探索頻度が、あらかじめ定めたしきい値より高いキー
(データレコード)を初回比較キ−の候補として洗いだ
す。これは、統計情報を用いてデ−タベ−スマネジメン
トシステムが自動的に選出しても良いし、デ−タベ−ス
の管理者が経験的に頻度を与えて選出しても良い。
In the case of leaf nodes (1 2 , 1 3 ...) A key (data record) whose search frequency is higher than a predetermined threshold value is selected as a candidate for the first comparison key. This may be automatically selected by the database management system using statistical information, or may be selected empirically by the administrator of the database based on experience.

【0021】初回比較キ−の候補を選出するときの基準
となる探索頻度のしきい値は、システムの諸情報を考慮
することにより様々な決定方法がありえるが、一つの目
安としては、一つのノ−ド中の平均キ−数をαとする
と、平均的なキ−の探索頻度のα/log2α倍の頻度
で探索するキ−を候補にすると一般的な2分探索法より
キ−の平均比較回数が少なくなると期待できる。
The threshold value of the search frequency, which serves as a reference when selecting a candidate for the first comparison key, can be determined in various ways by considering various information of the system, but one guideline is When the average number of keys in the node is α, when a key to be searched with a frequency of α / log 2 α times the average search frequency of keys is used as a candidate, a key is searched for by a general binary search method. It can be expected that the average number of times of comparison will decrease.

【0022】B木の各ノ−ド内の初回比較キ−位置記憶
域2への値の設定は、データベースのインデクスの再編
成などの時点でまとめて行う。先ず、B木の葉の各ノ−
ドについて、上記の手法によって選出した初回比較キ−
の候補がノ−ド内にあれば、そのうちの最も探索頻度の
高いキ−を格納しタエントリの番号をノ−ド内の初回比
較キ−位置記憶域2に設定する。B木の葉のノ−ドに初
回比較キ−の候補がなければ、初回比較キ−位置記憶域
2には値を設定しない。図1に示す例では、ノード12
の初回比較キー位置記憶域22にエントリ番号2が格納
され、ノード13の初回比較キー位置記憶域23に同じく
エントリ番号2が格納されている。
The setting of the value in the first comparison key position storage area 2 in each node of the B-tree is collectively performed at the time of reorganizing the index of the database. First, each leaf of B tree
The first comparison key selected by the above method
If the candidate is in the node, the key with the highest search frequency is stored and the number of the data entry is set in the first comparison key position storage area 2 in the node. If there is no candidate for the first comparison key in the node of the B tree, no value is set in the first comparison key position storage area 2. In the example shown in FIG. 1, node 1 2
The entry number 2 is stored in the first comparison key position storage area 2 2 of the above, and the entry number 2 is also stored in the first comparison key position storage area 2 3 of the node 1 3 .

【0023】葉のノード以外のノード(11)の場合 B木の葉のノ−ド以外のノ−ドについては、キ−の探索
頻度として、各エントリに格納されたキ−の下位につな
がる各ノ−ドの合計頻度を割り当て、合計頻度が最も大
きいキーを選出することにより初回比較キ−の選出を行
い、上記葉のノ−ドと同様に初回比較キ−位置記憶域2
へ当該キーを格納しているエントリの番号の設定を行
う。図1に示す例では、ノード11の初回比較キー位置
記憶域21にエントリ番号1が格納されている。
In the case of the node (1 1 ) other than the leaf node: For the nodes other than the leaf node of the B tree, each node connected to the lower order of the key stored in each entry is used as the key search frequency. -The first comparison key is selected by assigning the total frequency of the nodes and selecting the key with the highest total frequency.
Set the number of the entry that stores the key. In the example shown in FIG. 1, the entry number 1 is stored in the initial comparison key position storage area 2 1 of the node 1 1 .

【0024】次に、探索を行う時点での各ノ−ドでの2
分探索の手順を図2と図3のフロ−チャ−トを用いて説
明する。
Next, 2 in each node at the time of searching
The procedure of the minute search will be described with reference to the flowcharts of FIGS.

【0025】図2は、B木の葉のノ−ド(12,13)に
おける2分探索の手順を示すフロ−チャ−トである。最
初に、探索キーが与えられたとき、探索表3全体を探索
範囲とし(ステップ101)、初回比較キ−が指定され
ているかどうかを初回比較キ−位置記憶域2により判定
する(ステップ102)。初回比較キ−が指定されてい
る場合は、初回比較キ−を比較対象のキ−とする(ステ
ップ104)。初回比較キ−が指定されていない場合
は、探索範囲の中央の位置のキ−を比較対象のキ−とす
る(ステップ103)。次に、比較対象のキ−と探索キ
−を比較し(ステップ105)、その結果によって処理
を振り分ける(ステップ106)。比較対象キ−と探索
キ−が一致すれば、探索は成功に終わる(ステップ11
0)。比較対象キ−の方が探索キ−より大きければ、探
索範囲のうち比較対象キ−より小さい範囲を新たな探索
範囲とする(ステップ108)。比較対象キ−の方が探
索キ−より小さければ、探索範囲のうち比較対象キ−よ
り大きい範囲を新たな探索範囲とする(ステップ10
7)。次に、こうして求めた新たな探索範囲が空かどう
か判定し(ステップ109)、空であれば探索が失敗に
終わり(ステップ111)、空でなければ再度探索範囲
の中央の位置のキ−を比較対象のキ−として探索を進め
る(ステップ103)。
FIG. 2 is a flow chart showing the procedure of the binary search in the node (1 2 , 1 3 ) of the leaf B. First, when the search key is given, the entire search table 3 is set as the search range (step 101), and it is determined by the initial comparison key position storage area 2 whether the initial comparison key is designated (step 102). .. If the initial comparison key is specified, the initial comparison key is set as the key to be compared (step 104). If the initial comparison key is not designated, the key at the center of the search range is set as the key to be compared (step 103). Next, the key to be compared and the search key are compared (step 105), and the processing is sorted according to the result (step 106). If the comparison key and the search key match, the search ends successfully (step 11).
0). If the comparison target key is larger than the search key, a range smaller than the comparison target key in the search range is set as a new search range (step 108). If the comparison target key is smaller than the search key, a range larger than the comparison target key in the search range is set as a new search range (step 10).
7). Next, it is determined whether or not the new search range thus obtained is empty (step 109). If it is empty, the search ends in failure (step 111), and if it is not empty, the key at the center position of the search range is again searched. The search proceeds as a key to be compared (step 103).

【0026】図3は、B木の葉以外のノ−ドでの2分探
索の手順を示すフロ−チャ−トである。最初に、探索表
3全体を探索範囲とし(ステップ201)、初回比較キ
−が指定されているかどうかを初回比較キ−位置記憶域
2により判定する(ステップ202)。初回比較キ−が
指定されている場合は、初回比較キ−を比較対象のキ−
とする(ステップ204)。初回比較キ−が指定されて
いない場合は、探索範囲の中央の位置のキ−を比較対象
のキ−とする(ステップ203)。次に、比較対象のキ
−と探索キ−を比較し(ステップ205)、その結果に
よって処理を振り分ける(ステップ206)。比較対象
キ−と探索キ−が一致すれば、探索は成功に終わる(ス
テップ210)。比較対象キ−の方が探索キ−より小さ
ければ、探索範囲のうち比較対象キ−より大きい範囲を
新たな探索範囲とする(ステップ207)。
FIG. 3 is a flowchart showing the procedure of the binary search in the nodes other than the leaves of the B tree. First, the entire search table 3 is set as the search range (step 201), and it is determined by the initial comparison key position storage area 2 whether the initial comparison key is designated (step 202). If the initial comparison key is specified, the initial comparison key is the key to be compared.
(Step 204). If the initial comparison key is not specified, the key at the center of the search range is set as the key to be compared (step 203). Next, the key to be compared and the search key are compared (step 205), and the processing is sorted according to the result (step 206). If the comparison key and the search key match, the search ends successfully (step 210). If the comparison target key is smaller than the search key, a range larger than the comparison target key in the search range is set as a new search range (step 207).

【0027】比較対象キ−の方が探索キ−より大きい場
合には、次のように探索の成否を判定する。初回比較キ
−が記録されていて(ステップ212)、初回比較キ−
がノ−ド内の先頭のエントリに格納されたキ−であれば
(ステップ213)、探索は成功して終わる(ステップ
216)。また、初回比較キ−が指定されていて(ステ
ップ212)、初回比較キ−が格納されたエントリの隣
のエントリ(エントリ番号が小さい方の隣)にキ−があ
る場合、そのキ−と探索キ−を比較し(ステップ21
4)、比較の結果探索キ−の方が大きいとき(ステップ
215)、初回比較キーが探索キーとなり、探索は成功
に終わる(217)。
When the compared key is larger than the search key, the success or failure of the search is determined as follows. The initial comparison key is recorded (step 212), and the initial comparison key is recorded.
Is the key stored in the first entry in the node (step 213), the search ends successfully (step 216). If the first comparison key is specified (step 212) and there is a key in the entry next to the entry in which the first comparison key is stored (next to the entry with the smaller entry number), that key and search are performed. Compare the keys (step 21
4) If the comparison result search key is larger (step 215), the initial comparison key becomes the search key, and the search ends in success (217).

【0028】上記以外の場合は、探索範囲のうち比較対
象キ−より大きい範囲を新たな探索範囲とする(ステッ
プ208)。次に、こうして求めた、新たな探索範囲が
空がどうか判定し(ステップ209)、空であれば探索
が失敗に終わり(ステップ211)、空でなければ再度
探索範囲の中央の位置のキ−を比較対象のキ−として探
索を進める(ステップ203)。
In cases other than the above, a range larger than the comparison target key in the search range is set as a new search range (step 208). Next, it is determined whether or not the new search range thus obtained is empty (step 209). If it is empty, the search ends in failure (step 211). If it is not empty, the key at the center position of the search range is again searched. The search is proceeded with as a key to be compared (step 203).

【0029】図4は、上記したデータベースの探索を行
うシステム構成の一例を示すブロック図である。図4に
示すように、データベース305の中には、データを格
納するためのデータレコード部307と、データレコー
ドの位置を検索するためのB木306とが設けれてい
る。データベースマネジメントシステム303は、ユー
ザアプリケーションプログラム301や端末302か
ら、データベースの検索要求を受け取る。マネジメント
システム303は、上記検索要求を処理するために、そ
の中に含む2分探索手段304を用いて、B木306の
中を探索し、検索要求に該当するデータレコードを検索
する。
FIG. 4 is a block diagram showing an example of a system configuration for searching the above-mentioned database. As shown in FIG. 4, in the database 305, a data record section 307 for storing data and a B tree 306 for searching the position of the data record are provided. The database management system 303 receives a database search request from the user application program 301 and the terminal 302. In order to process the search request, the management system 303 searches the B-tree 306 by using the binary search means 304 included therein to search for a data record corresponding to the search request.

【0030】[0030]

【発明の効果】本発明によれば、特定のキ−に探索が集
中する場合に2分探索法のキ−の平均比較回数を減らす
ことができる。例えば、B木に適用すると、B木の各ノ
−ド毎に本発明の方法を適用することができるので効果
が大きい。また、探索対象のキ−が属性の異なる複数の
キ−の合成である場合には、キ−の一回の比較に多くの
時間が必要であるので、本発明によるキ−の比較時間の
短縮の効果は大きい。
According to the present invention, when the search concentrates on a specific key, the average number of comparisons of the keys of the binary search method can be reduced. For example, when the method is applied to a B-tree, the method of the present invention can be applied to each node of the B-tree, which is very effective. Further, when the key to be searched is a combination of a plurality of keys having different attributes, a large amount of time is required for one key comparison, so that the key comparison time according to the present invention is shortened. Has a great effect.

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

【図1】本発明をデ−タベ−スのインデクスを構成する
B木に適用した実施例の構成を示す図。
FIG. 1 is a diagram showing the configuration of an embodiment in which the present invention is applied to a B-tree that constitutes a database index.

【図2】B木の葉のノ−ドに対する2分探索法の手順を
示すフロ−チャ−ト。
FIG. 2 is a flowchart showing the procedure of the binary search method for the leaf node of B tree.

【図3】B木の葉以外のノ−ドに対する2分探索法の手
順を示すフロ−チャ−ト。
FIG. 3 is a flow chart showing the procedure of a binary search method for a node other than B-leaf.

【図4】図1に示すデータベースの探索を行うシステム
構成の一例を示すブロック図。
FIG. 4 is a block diagram showing an example of a system configuration for searching the database shown in FIG.

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

1,12,13…B木のノ−ド,21,22,23…初回比
較キ−位置記憶域,3…探索表,41,42,…データレ
コードのキー値,51,52,…リンク,61,62…デ−
タレコ−ド,7…B木,81,82…デ−タレコ−ドへの
リンク
1 1 , 1 2 , 1 3 ... B-tree node, 2 1 , 2 2 , 2 3 ... First comparison key position storage area, 3 ... Lookup table, 4 1 , 4 2 , ... Key value of data record , 5 1 , 5 2 , ... Link, 6 1 , 6 2 ... De-
Tareko - de, 7 ... B tree, 8 1, 8 2 ... de - Tareko - link to the de

Claims (1)

【特許請求の範囲】[Claims] 【請求項1】探索キー値と探索表の中央に位置するキー
値とを比較して、探索キー値を検索するデータベースの
2分探索法において、最初の比較処理を探索頻度の最も
高いキ−値と行うことを特徴とするデータベースの2分
探索方法。
1. In a binary search method of a database for searching a search key value by comparing a search key value with a key value located in the center of a search table, the first comparison processing is performed by the key with the highest search frequency. A binary search method for a database characterized by performing a value.
JP3327622A 1991-12-11 1991-12-11 Binary search method of data base Pending JPH05165894A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP3327622A JPH05165894A (en) 1991-12-11 1991-12-11 Binary search method of data base

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP3327622A JPH05165894A (en) 1991-12-11 1991-12-11 Binary search method of data base

Publications (1)

Publication Number Publication Date
JPH05165894A true JPH05165894A (en) 1993-07-02

Family

ID=18201111

Family Applications (1)

Application Number Title Priority Date Filing Date
JP3327622A Pending JPH05165894A (en) 1991-12-11 1991-12-11 Binary search method of data base

Country Status (1)

Country Link
JP (1) JPH05165894A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11016299B2 (en) 2017-11-27 2021-05-25 Fujitsu Limited Storage medium, control method, and control device for changing setting values of a wearable apparatus

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11016299B2 (en) 2017-11-27 2021-05-25 Fujitsu Limited Storage medium, control method, and control device for changing setting values of a wearable apparatus

Similar Documents

Publication Publication Date Title
US6668263B1 (en) Method and system for efficiently searching for free space in a table of a relational database having a clustering index
US5404510A (en) Database index design based upon request importance and the reuse and modification of similar existing indexes
US6741985B2 (en) Document retrieval system and search method using word set and character look-up tables
US6360213B1 (en) System and method for continuously adaptive indexes
US7765215B2 (en) System and method for providing a trustworthy inverted index to enable searching of records
US20060026138A1 (en) Real-time indexes
US7526497B2 (en) Database retrieval apparatus, retrieval method, storage medium, and program
US7856436B2 (en) Dynamic holds of record dispositions during record management
US20070294243A1 (en) Database for efficient fuzzy matching
US8583657B2 (en) Method and apparatus for using a hash-partitioned index to access a table that is not partitioned or partitioned independently of the hash partitioned index
EP0369052A1 (en) Data base access system
US6735600B1 (en) Editing protocol for flexible search engines
US7979440B2 (en) System and article of manufacture for efficient evaluation of index screening predicates
US20080270407A1 (en) System for ensuring referential integrity in highly concurrent database environments
US7809674B2 (en) Supporting B+tree indexes on primary B+tree structures with large primary keys
US5619199A (en) Order preserving run length encoding with compression codeword extraction for comparisons
JP2002259442A (en) Database search method and recording medium
JPH05165894A (en) Binary search method of data base
US6076089A (en) Computer system for retrieval of information
JP2000339332A (en) Medium recording retrieval index, method and device for updating retrieval index and medium recording its program
CN111767289A (en) Data storage method and device based on memory database
JP2002140218A (en) Data processing method, computer-readable recording medium and data processing device
JPH10240741A (en) Managing method for tree structure type data
Blok et al. A selectivity model for fragmented relations in information retrieval
JPH11143904A (en) Data base retrieval method and device and recording medium recording data base retrieval program