JP5186270B2 - Database cache system - Google Patents
Database cache system Download PDFInfo
- Publication number
- JP5186270B2 JP5186270B2 JP2008112945A JP2008112945A JP5186270B2 JP 5186270 B2 JP5186270 B2 JP 5186270B2 JP 2008112945 A JP2008112945 A JP 2008112945A JP 2008112945 A JP2008112945 A JP 2008112945A JP 5186270 B2 JP5186270 B2 JP 5186270B2
- Authority
- JP
- Japan
- Prior art keywords
- data
- identification information
- record
- database
- map
- 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.)
- Expired - Fee Related
Links
Images
Description
本発明は、データベースのキャッシュシステムに関し、特に、インサート・オンリー方式のデータベースに適用できるキャッシュシステムに関する。 The present invention relates to a database cache system, and more particularly to a cache system applicable to an insert-only database.
データベースへのアクセス方式において、インサート・オンリー(insert only)と呼ばれる方式がある。この方式は、データベース・テーブルへの更新操作を、既存レコードに対して更新(update)や削除(delete)を実際に行うのではなく、常に、新規レコードの挿入(insert)によって行うものである。この方式では、データベース・テーブルの各レコードに、データの識別情報であるキー識別子(key identifier)と共に、CRUD値(CRUD value)と呼ばれる操作内容を示す情報と、操作が行われた時刻を示す情報(タイムスタンプ)とが格納される。そして、変更操作の度に新たなレコードが挿入されるため、同一のキー識別子を持ちタイムスタンプの値(以下、タイムスタンプ情報と呼ぶ)が異なる複数のレコードが変更履歴の数だけ存在することとなる。ここで、CRUD値の「CRUD」は、「作成(CReate)」、「更新(Update)」、「削除(Delete)」の頭文字である。 As a database access method, there is a method called insert only. In this method, an update operation to a database table is not performed by actually updating (delete) or deleting (delete) an existing record, but is always performed by inserting a new record. In this method, each record of the database table includes, together with a key identifier that is data identification information, information indicating an operation content called a CRUD value, and information indicating a time when the operation is performed. (Time stamp) is stored. Since a new record is inserted every time a change operation is performed, a plurality of records having the same key identifier and different time stamp values (hereinafter referred to as time stamp information) exist as many as the number of change histories. Become. Here, the CRUD value “CRUD” is an acronym for “Create”, “Update”, and “Delete”.
このインサート・オンリー方式は、過去の変更履歴を全て保存するという監査要求事項(auditing requirement)を満たす必要以外にも、ロック・コンテンション(lock contention)の確率を減らすという設計上の要求から採用されることも多い。例えば、金融に関わるアプリケーションを例に考えると、オンラインによる処理は、一般に、現在の口座残高その他の情報を表示したり振替処理をしたりするなど、最新のデータを使って処理が行われる。これに対して、バッチ処理では、過去のある時点における残高に対して利率計算を行ったり、月次報告書を作成したりする処理が行われる。すなわち、オンライン処理とバッチ処理における起点となるタイムスタンプ情報が各々異なるため、これらの処理を同時に実行し、同一のキー識別子を持つデータにアクセスする場合でも、別々のレコードにアクセスすることになる。そのため、ロック・コンテンションが起きにくくなる。 This insert-only method was adopted because of the design requirement to reduce the probability of lock contention, in addition to the need to satisfy the auditing requirement of saving all past change history. There are many cases. For example, taking an application related to finance as an example, online processing is generally performed using the latest data, such as displaying the current account balance and other information, and performing transfer processing. On the other hand, in batch processing, interest rate calculation is performed on the balance at a certain point in the past, and a monthly report is created. That is, since the time stamp information which is the starting point in the online processing and the batch processing is different, even when these processings are executed simultaneously and data having the same key identifier is accessed, different records are accessed. As a result, lock contention is less likely to occur.
ところで、データベースに対するアクセス等の処理を高速化するための一般的な手段として、キャッシュメモリを用いる方法がある(例えば、特許文献1参照)。すなわち、データベースからフェッチしたデータをサーバにおいてキャッシュしておく。そして、繰り返し発行されるクエリに対しては、パラメータに基づきハッシュ・テーブルを引くなどして、対象とするデータがキャッシュ内で利用可能かどうかチェックする。 By the way, as a general means for speeding up processing such as access to a database, there is a method using a cache memory (for example, see Patent Document 1). That is, the data fetched from the database is cached in the server. For queries that are repeatedly issued, it is checked whether the target data can be used in the cache by, for example, drawing a hash table based on the parameters.
インサート・オンリー方式では、次のような問題がある。
第1に、データベースへのアクセスにおいて、常にタイムスタンプ情報を指定したり、CRUD値をチェックしたりしなければならない。そのため、副照会を使うなどの操作が必要となり、クエリ処理が複雑で重くなる。
第2に、データの一部分のみを変更する場合においても、データベース・テーブルにおける対象となるカラム(column)だけを選択的にフェッチして書き出すことはできない。そのため、一旦は全てのカラム内容をフェッチする必要がある。
さらに、単にデータベース中に今あるデータの中から最新のものを1レコードフェッチしたいという場合でも、タイムスタンプ情報を指定する必要があるため、呼び出し側で現在のタイムスタンプ情報(currentTimeStamp)を生成して渡してやらなければならない。
The insert-only method has the following problems.
First, in accessing the database, time stamp information must always be specified and the CRUD value must be checked. For this reason, an operation such as using a subquery is required, and the query processing becomes complicated and heavy.
Second, even when only a part of the data is changed, it is not possible to selectively fetch and write only the target column in the database table. Therefore, it is necessary to fetch all column contents once.
Furthermore, even if you want to fetch one record of the latest data from the database, you need to specify the time stamp information, so the caller generates the current time stamp information (currentTimeStamp) I have to give it.
アプリケーションの内容によっては、これらのオーバーヘッドがシステム全体の性能低下を引き起こす原因となる。特に、バッチ処理などのようにビジネスロジックが繰り返し実行される場合には、このオーバーヘッドは無視できないものとなる。また、更新がほとんど行われないようなテーブルでも、トランザクションの度にコストのかかるデータベースアクセスを繰り返すのは、アプリケーションの性能面で問題となる。 Depending on the contents of the application, these overheads can cause a decrease in the performance of the entire system. In particular, when business logic is repeatedly executed, such as in batch processing, this overhead cannot be ignored. Even for tables that are rarely updated, it is problematic in terms of application performance to repeat expensive database access for each transaction.
このような問題に対し、通常のデータベースアクセスであれば、キャッシュメモリを用いて高速化を図ることが考えられる。上記のように、インサート・オンリー方式のアプリケーションでは、キー識別子とタイムスタンプ情報の組み合わせでレコードが特定されるので、この組み合わせでクエリがかけられ、またこの組み合わせを検索キーとしてハッシュ・テーブルにデータがキャッシュされることとなる。そして、タイムスタンプ情報はクエリ作成のための読み出しごとに毎回異なるデータが渡される。そのため、単にハッシュ・テーブルに基づいて行われる従来の検索方法ではキャッシュはヒットせず、冗長な読み出しに対して有効な手段とならなかった。例えば、あるキー識別子の最新のレコードを読み出そうとする場合、そのキー識別子を持つデータがキャッシュされている場合でも、そのキャッシュデータがそのキー識別子を持つレコードの中で最新のレコードか否かを判断することはできない。 For such a problem, it is conceivable to increase the speed by using a cache memory for normal database access. As described above, in an insert-only application, a record is specified by a combination of a key identifier and time stamp information. Therefore, a query is applied by this combination, and data is stored in the hash table using this combination as a search key. It will be cached. As the time stamp information, different data is passed each time read for query creation. For this reason, the cache is not hit in the conventional search method performed simply based on the hash table, and is not an effective means for redundant reading. For example, when trying to read the latest record with a key identifier, whether or not the cached data is the latest record among the records with the key identifier even if the data with the key identifier is cached Cannot be judged.
本発明は、これらの課題を解決し、インサート・オンリー方式のアプリケーションにおいても有効なキャッシュシステムを実現することを目的とする。 An object of the present invention is to solve these problems and to realize a cache system that is effective even in an insert-only system application.
上記の目的を達成するため、本発明は、次のようなシステムとして構成される。このシステムは、データの作成、更新、削除が行われるたびに同一の識別情報が付与されたデータのレコードを追加するデータベースにおいて、このデータベースから読み出されたデータをキャッシュする保持部と、この保持部にキャッシュされるデータを管理する管理部とを備える。保持部は、データの識別情報を登録するテーブルと、このテーブルに登録された識別情報に個別に対応付けられ、データベースにおけるこの識別情報を持つレコードを示すエントリを格納するマップとを備える。管理部は、識別情報およびレコードを指定する情報を含むクエリを受け付けて保持部を検索し、該当するデータがキャッシュされていればそのデータを読み出し、該当するデータがキャッシュされていなければ、そのデータをデータベースから取得し、保持部のマップにおけるクエリにより指定された識別情報およびレコードに対応するエントリに関連付けてこのデータをキャッシュさせる。 In order to achieve the above object, the present invention is configured as the following system. This system includes a holding unit that caches data read from the database and a holding unit that adds a data record to which the same identification information is added every time data is created, updated, or deleted. A management unit that manages data cached in the unit. The holding unit includes a table for registering identification information of data, and a map for storing an entry indicating a record having the identification information in the database, individually associated with the identification information registered in the table. The management unit accepts a query including identification information and information specifying a record, searches the holding unit, reads the data if the corresponding data is cached, and reads the data if the corresponding data is not cached. Is retrieved from the database, and this data is cached in association with the entry corresponding to the identification information and record specified by the query in the map of the holding unit.
ここで、マップは、データベースに格納されており、テーブルに登録されていない所定の識別情報を持つデータに対して初めてアクセスが行われた際に生成される。
マップのエントリには、レコードが作成された際にレコードに付与される時間情報が記録される。そして、管理部は、レコードを指定する情報としてこの時間情報が一意に定まる条件を記載したクエリを受け付け、この条件にしたがって特定される時間情報を持つエントリを、このクエリにより指定されたレコードを示すエントリとする。
より詳細には、この時間情報は、レコードが作成される原因となったデータに対する操作が行われた時刻を表すタイムスタンプである。
クエリにより指定された識別情報を持つデータがデータベースに存在しない場合、その旨を示す情報が、テーブルに登録された識別情報に対応付けられて保持部に保持される。
クエリの実行により識別情報が段階的に指定される場合、テーブルとマップの間に補助エントリが設けられ、クエリに記述された最上位の識別情報がテーブルに登録され、クエリの実行により得られる下位の識別情報がテーブルの識別情報に対応付けられて補助エントリに登録され、補助エントリに登録された最下位の識別情報にマップが対応付けられる。
データベースにおいて所定の識別情報を持つデータのレコードが追加された場合に、保持部において、テーブルに登録された識別情報および識別情報に対応付けられたマップが削除され、マップのエントリに関連付けられたデータがキャッシュされているときはキャッシュされているデータも削除される。
あるいは、データベースにおいて所定の識別情報を持つデータのレコードが追加された場合に、識別情報に対応付けられたマップに、このレコードに関連付けられたエントリが追加される。
Here, the map is stored in the database and is generated when data having predetermined identification information that is not registered in the table is accessed for the first time.
In the map entry, time information given to the record when the record is created is recorded. Then, the management unit accepts a query that describes a condition for uniquely determining this time information as information for specifying a record, and indicates an entry having time information specified according to this condition as the record specified by this query. Entry.
More specifically, this time information is a time stamp indicating the time when an operation is performed on the data that caused the record to be created.
When data having identification information specified by the query does not exist in the database, information indicating that is stored in the holding unit in association with the identification information registered in the table.
When identification information is specified step by step by executing a query, an auxiliary entry is provided between the table and the map, and the highest-level identification information described in the query is registered in the table, and the lower level obtained by executing the query The identification information is associated with the identification information in the table and registered in the auxiliary entry, and the map is associated with the lowest-level identification information registered in the auxiliary entry.
When a record of data having predetermined identification information is added in the database, the identification information registered in the table and the map associated with the identification information are deleted in the holding unit, and the data associated with the map entry When is cached, the cached data is also deleted.
Alternatively, when a data record having predetermined identification information is added in the database, an entry associated with this record is added to the map associated with the identification information.
また、本発明は、次のようなデータ構造としても実現される。このデータ構造は、データの作成、更新、削除が行われるたびに同一の識別情報が付与されたデータのレコードを追加するデータベースにおける、識別情報を登録するテーブルと、テーブルに登録された識別情報に個別に対応付けられ、データベースにおける識別情報を持つレコードを示すエントリを格納するマップとを備え、所定のクエリに基づきデータベースから取得されたデータが、マップにおけるクエリにより指定された識別情報およびレコードに対応するエントリに関連付けられてキャッシュされる。
このマップには、データベースのレコードが作成された際にレコードに付与される時間情報に基づき、エントリが時系列に並べられて格納される。
また、テーブルに登録された識別情報を持つデータがデータベースに存在しない場合、マップに代えて、データが存在しない旨を示す情報が保持される。
The present invention is also realized as the following data structure. This data structure consists of a table for registering identification information in the database to which data records to which the same identification information is assigned each time data is created, updated, or deleted, and the identification information registered in the table. And a map that stores entries indicating records with identification information in the database, and the data obtained from the database based on a given query corresponds to the identification information and records specified by the query in the map It is cached in association with the entry.
In this map, entries are arranged in time series and stored based on time information given to the records when the database records are created.
When data having identification information registered in the table does not exist in the database, information indicating that no data exists is held instead of the map.
また、本発明は、次のような方法としても実現される。この方法は、データの作成、更新、削除が行われるたびに同一の識別情報が付与されたデータのレコードを追加するデータベースのキャッシュ方法であって、識別情報およびレコードを指定する情報を含むクエリを受け付け、データの識別情報を登録するテーブルに対して、クエリにより指定された識別情報を検索するステップと、テーブルにクエリにより指定された識別情報が存在しない場合、この識別情報をテーブルに登録し、この識別情報に対応づけてデータベースにおけるこの識別情報を持つレコードを示すエントリを格納するマップを生成するステップと、テーブルにクエリにより指定された識別情報が存在する場合、この識別情報に対応付けられたマップのエントリに関連付けられたデータがキャッシュされているならばそのデータを読み出し、エントリに関連付けられたデータがキャッシュされていないならばデータベースから読み出されたデータをこのエントリに関連付けてキャッシュさせるステップとを含む。 The present invention is also realized as the following method. This method is a database caching method that adds a record of data to which the same identification information is assigned every time data is created, updated, or deleted, and includes a query including identification information and information specifying the record. Accepting and searching for the identification information specified by the query with respect to the table for registering the identification information of the data, and if the identification information specified by the query does not exist in the table, register this identification information in the table, A step of generating a map storing an entry indicating a record having the identification information in the database in association with the identification information, and when the identification information specified by the query exists in the table, the map is associated with the identification information. If the data associated with the map entry is cached, Reads data, the data associated with the entry and a step of caching in association with data read from the database if not cached in the entry.
さらに本発明は、コンピュータを制御して上記のシステムにおける各機能を実現するプログラムや、上記の方法における各ステップに対応する処理をコンピュータに実行させるプログラムとして実現することもできる。このプログラムは、磁気ディスクや光ディスク、半導体メモリ、その他の記録媒体に格納して配布したり、ネットワークを介して配信したりすることにより提供することができる。 Furthermore, the present invention can also be realized as a program that controls a computer to realize each function in the above system or a program that causes a computer to execute processing corresponding to each step in the above method. This program can be provided by being stored and distributed in a magnetic disk, an optical disk, a semiconductor memory, or other recording medium, or distributed via a network.
以上のように構成された本発明によれば、データベースにおけるインサート・オンリー方式のアプリケーションにおいても有効なキャッシュシステムを実現できる。 According to the present invention configured as described above, it is possible to realize a cache system that is effective even in an insert-only application in a database.
以下、添付図面を参照して、本発明の実施形態について詳細に説明する。
<システム構成>
図1は、本実施形態が適用されるデータベースシステムの機能構成例を示す図である。
図1に示すように、本実施形態のデータベースシステム100は、データベース110と、アクセス部120とを備え、かつキャッシュシステムを実現するためのデータ保持部130と、キャッシュ管理部140と、マップ作成部150とを備える。また別の構成例として、キャッシュシステムの各構成部130、140、150は、データベースシステムの一部とせず、データベースをアクセスするアプリケーションシステムの一部として実現しても良い。さらに、アプリケーションシステムとデータベースシステムの中間にある独立したレイヤーとして実現することもできる。これらの場合、アクセス部120は、アプリケーションシステムにおいてデータをアクセスする部分を指す。
Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings.
<System configuration>
FIG. 1 is a diagram illustrating a functional configuration example of a database system to which the present embodiment is applied.
As shown in FIG. 1, the
図2は、データベースシステム100を構成するコンピュータのハードウェア構成例を示す図である。
図2に示すコンピュータ10は、演算手段であるCPU(Central Processing Unit)10aと、記憶手段であるメイン・メモリ10cおよび磁気ディスク装置(HDD:Hard Disk Drive)10gを備える。また、ネットワークを介して外部装置に接続するためのネットワーク・インタフェース・カード10fと、表示出力を行うためのビデオ・カード10dおよび表示装置10jと、音声出力を行うための音声機構10hとを備える。さらに、キーボードやマウス等の入力デバイス10iを備える。
FIG. 2 is a diagram illustrating a hardware configuration example of a computer constituting the
The
図2に示すように、メイン・メモリ10cおよびビデオ・カード10dは、システム・コントローラ10bを介してCPU10aに接続されている。また、ネットワーク・インタフェース・カード10f、磁気ディスク装置10g、音声機構10hおよび入力デバイス10iは、I/Oコントローラ10eを介してシステム・コントローラ10bと接続されている。各構成要素は、システム・バスや入出力バス等の各種のバスによって接続される。例えば、CPU10aとメイン・メモリ10cの間は、システム・バスやメモリ・バスにより接続される。また、CPU10aと磁気ディスク装置10g、ネットワーク・インタフェース・カード10f、ビデオ・カード10d、音声機構10h、入力デバイス10i等との間は、PCI(Peripheral Components Interconnect)、PCI Express、シリアルATA(AT Attachment)、USB(Universal Serial Bus)、AGP(Accelerated Graphics Port)等の入出力バスにより接続される。
As shown in FIG. 2, the
なお、図2は、本実施形態が適用されるのに好適なコンピュータのハードウェア構成を例示するに過ぎず、実際の各サーバが図示の構成に限定されないことは言うまでもない。例えば、ビデオ・カード10dを設ける代わりに、ビデオメモリのみを搭載し、CPU10aにてイメージ・データを処理する構成としても良い。また、音声機構10hを独立した構成とせず、システム・コントローラ10bやI/Oコントローラ10eを構成するチップセットの機能として備えるようにしても良い。また、補助記憶装置として磁気ディスク装置10gの他に、各種の光学ディスクやフレキシブル・ディスクをメディアとするドライブを設けても良い。表示装置10jとしては、主として液晶ディスプレイが用いられるが、その他、CRTディスプレイやプラズマ・ディスプレイ等、任意の方式のディスプレイを用いて良い。
Note that FIG. 2 merely exemplifies a hardware configuration of a computer suitable for application of the present embodiment, and it is needless to say that each actual server is not limited to the illustrated configuration. For example, instead of providing the
図1に示したデータベースシステム100において、アクセス部120、キャッシュ管理部140、マップ作成部150の各機能は、例えば図2に示したコンピュータにおいて、メイン・メモリ10cに読み込まれたプログラムをCPU10aが実行することにより実現される。データベース110は、例えば磁気ディスク装置10gにより実現され、キャッシュシステムのデータ保持部130は、例えばメイン・メモリ10cにキャッシュ領域を設けて実現される。
In the
図1において、データベース110は、検索対象のデータを格納する。本実施形態において、データベース110に対するアクセスは、インサート・オンリー方式で行われる。この方式では、データの更新操作の度にデータベース110に新規レコードが追加作成される。そして、作成されたレコードには、データを識別するためのキー識別子と、レコードが作成される原因となった操作が行われた時刻を示すタイムスタンプ情報が記録される。したがって、データベース110には、同一のキー識別子であってもタイムスタンプ情報の異なる複数のレコードが変更履歴の数だけ存在する。すなわち、タイムスタンプ情報は、同一のキー識別子を持つレコードの識別情報として用いることができる。また、各レコードには、操作内容を表すCRUD値が記録される。なお、データの読み出しでは、データベース110の状態は変更されないので、新たなレコードが生成(インサート)されることはない。したがって、CRUD値の欄(カラム)には「作成」、「更新」、「削除」のいずれかが記録されることとなる。
In FIG. 1, a
図3は、データベース110の構成例を示す図である。
図3に示すデータベース110には、キー識別子「10032752046925」に関して、タイムスタンプ情報の異なる3つのレコードが存在している。これらの各レコードのCRUD値は、タイムスタンプ情報の古いものから順に「C」、「U」、「D」であり、「C」は作成(Create)、「U」は更新(Update)、「D」は削除(Delete)を表している。すなわち、図3の例では、キー識別子「10032752046925」のデータが、作成され、1回更新された後に削除されたことが示されている。
FIG. 3 is a diagram illustrating a configuration example of the
In the
アクセス部120は、SQL等で記述されたクエリを受け付けてデータベース110にアクセスし、レコードの作成、読み出し、更新、削除等の処理を実行する。また、アクセス部120は、データベース110へのアクセスを行う際に、キャッシュ管理部140にキャッシュの操作を指示する。
The
データ保持部130は、キャッシュデータを保持する。本実施形態では、キー識別子に対するハッシュ・テーブルと、キー識別子ごとの全変更履歴を表現するマップと呼ぶデータ構造とを組み合わせたデータ構造により、キャッシュデータが保持される。このデータ構造の詳細については後述する。
The
キャッシュ管理部140は、データ保持部130に保持されるキャッシュデータを管理する。そして、アクセス部120からの指示に応じて、データのキャッシュに関する操作を行う。具体的には、アクセス部120による読み出し要求のクエリに該当するレコードを検索し、検索結果に応じて応答を返す。該当のレコードがキャッシュされていない場合は、読み出されたレコードをキャッシュする。また、クエリに該当するキー識別子がデータ保持部130のハッシュ・テーブルに存在しない場合は、ハッシュ・テーブルにキー識別子を登録し、そのキー識別子に関するマップをマップ作成部150に作成させる。
The
マップ作成部150は、キャッシュ管理部140の制御により、指示されたキー識別子のレコードのマップを作成する。マップは、キー識別子ごとにレコードの変更履歴を時系列に記録したものである。このマップを含むキャッシュのデータ構造について、以下に説明する。
The
<キャッシュのデータ構造>
図4は、本実施形態におけるキャッシュのデータ構造の例を示す図である。図5は、図4におけるマップエントリのデータ構造の例を示す図である。
図4に示すように、本実施形態のキャッシュはハッシュ・テーブル410とマップ420とを組み合わせたデータ構造を持つ。図4において、ハッシュ・テーブル410には、少なくとも1回以上読み出しが行われたキー識別子とそのキー識別子に対応付けられたマップ420が登録される。図4のハッシュ・テーブル410において、灰色で示された箇所を、キー識別子が登録された箇所とする。
<Cache data structure>
FIG. 4 is a diagram showing an example of the data structure of the cache in this embodiment. FIG. 5 is a diagram showing an example of the data structure of the map entry in FIG.
As shown in FIG. 4, the cache of this embodiment has a data structure in which a hash table 410 and a
ハッシュ・テーブル410にキー識別子が登録されると、このキー識別子のマップ420が作成される。このマップ420には、タイムスタンプ情報(timeStamp)、CRUD値(crudVal)、データオブジェクト(entryObj)が記録されたマップエントリがタイムスタンプ情報の降順(すなわち時系列)で並べられている。データオブジェクトは、マップエントリに対応するキャッシュされたレコードの内容へのポインタであり、初期的には「null」となる。例えば、図4に示すマップエントリ421には、タイムスタンプ情報「TS1」、CRUD値「U(更新)」、データオブジェクト「null」が記録されている。
When a key identifier is registered in the hash table 410, a
マップ420は、データベース110に格納されているデータであって、ハッシュ・テーブル410に登録されていない所定のキー識別子を持つデータが、アクセス部120により初めてアクセスされた際に作成される。この際、各マップエントリのデータオブジェクトの項目には「null」が記録される。これ以降、このキー識別子を持ち、所定のタイムスタンプ情報を持つレコードが読み出されると、キー識別子およびタイムスタンプ情報が対応するマップエントリのデータオブジェクトの項目に、データベース110から読み出されてデータ保持部130にキャッシュされたレコードの内容へのポインタが記録される。図4に示す例では、マップエントリ422において、データオブジェクトに、対応するレコードの内容が記録されている。
The
クエリにて指定されたキー識別子を持つデータが存在しない場合、キャッシュ管理部140は、そのキー識別子のマップを作成することができない。この場合、キャッシュ管理部140は、そのキー識別子をハッシュ・テーブル410に登録し、マップ420の代わりに、そのキー識別子を持つデータが存在しないことを示すデータを対応付けてデータ保持部130に保持させる。図4に示す例では、データ423が、該当するキー識別子を持つデータが存在しないことを示している。
If there is no data having the key identifier specified in the query, the
上記のマップの作成は、キャッシュ管理部140が、対象とするキー識別子を持つ各レコードからタイムスタンプ情報とCRUD値だけをフェッチする専用のクエリを発行することで実行される。マップ作成用のクエリの具体的な内容は、元のデータフェッチの内容(クエリ)によって異なる。例えば、「主照会でバインドされたキー識別子を持つ(複数の)レコードに対して、指定されたタイムスタンプ情報以前で最新の1レコードを副照会で選択し、そのCRUD値が「D(削除)」でないものを返す」というようなデータフェッチが行われる場合を考える。このようなアクセスが行われる際のクエリ(SQL文)は、例えば図6に示すようなものになる。そして、これに対応するマップを作成するための専用のクエリとクエリ結果からデータ構造を生成するコードは、図7のようになる。
The creation of the map is executed by the
ところで、ハッシュ・テーブル410にキー識別子およびマップ420が存在するデータに対して、読み出し以外のアクセスが行われた場合は、データベース110における新たなレコードの生成(インサート)を伴うため、データベース110に格納されているレコードとマップ420の内容とが整合しなくなる。この場合、キャッシュ管理部140は、そのキー識別子についてのキャッシュを一旦解放する。すなわち、ハッシュ・テーブル410のキー識別子およびキー識別子に対応付けられたマップ420を削除し、さらにマップ420のマップエントリに対応付けられて保持されたレコードも削除する。そして、同一のキー識別子について次にアクセスが行われた際に、再びハッシュ・テーブル410への登録およびマップの作成を行う。
By the way, when an access other than reading is performed on the data in which the key identifier and the
また、データベース110に新しいレコードが生成された際にキャッシュを解放するのではなく、マップ420を更新して対応することも可能である。データベース110に対するレコードの生成は最新のタイムスタンプ情報を付して行われる。そこで、キャッシュ管理部140は、新しいマップエントリを作成し、タイムスタンプ情報、CRUD値、データオブジェクトをセットした後、データ保持部130内の該当するマップ420の先頭に、この新たなマップエントリを追加する。
Further, instead of releasing the cache when a new record is generated in the
ここで、データベース110が更新されたか否かのチェックは、従来技術をそのまま適用可能であるが、本実施形態における、マップ420によってキャッシュを管理するという構造を利用して、次のような簡単な方法でも行うことができる。すなわち、データベース110内で、与えられたキー識別子をもつレコードの数を返す軽量なクエリを発行し、キャッシュされているデータが使用可能かチェックするという方法である。クエリからの戻り値が、現在のマップ420のエントリ数と合致すれば、このキー識別子に関し、マップ420の作成以後データベース110の更新はないと判断できる。したがって、キャッシュされているデータはそのまま使用可能である。一方、戻り値がマップ420のエントリ数よりも大きい場合は、マップ420の作成以後データベース110に変更があったと判断できる。したがって、上記のような処理(キャッシュの解放またはマップ420の更新)が行われる。なお、レコード数を返す軽量なクエリは、例えば図7で示されるようなマップ420の作成手続きの場合、
“select count(*) from TABLE where KEY_IDFR = ?”
のようになる。
Here, for checking whether the
“Select count (*) from TABLE where KEY_IDFR =?”
become that way.
図4に示したデータ構造を用いれば、ハッシュ・テーブル410にキー識別子が登録されたデータに関しては、データベース110においてそのキー識別子を持つ全てのレコードに関するタイムスタンプ情報を含む情報がマップ420に記録される。したがって、クエリに付与されたタイムスタンプ情報を基準としてどのようなレコードを取得しようとする場合にも、そのレコードがマップ420上のどのエントリに対応し、そのレコードの内容がキャッシュされているか否かを判断することができる。したがって、該当するレコードがキャッシュされていれば、そのレコードを読み出して返し、該当するレコードがキャッシュされていなければ、アクセス部120によるデータベース110の検索に移行した後、検索結果を取得してデータ保持部130にキャッシュすれば良い。また、既に検索が行われたもののデータベース110にデータが存在しないことが分かっている所定のキー識別子に関して、ハッシュ・テーブル410にデータが存在しないことを示す情報を対応付けることで、データベース110を実際に検索することなく、所望のデータが存在しないことを認識することができる。
If the data structure shown in FIG. 4 is used, with respect to data in which the key identifier is registered in the hash table 410, information including time stamp information regarding all records having the key identifier in the
<キャッシュシステムの動作>
次に、データ保持部130、キャッシュ管理部140およびマップ作成部150により構成されるキャッシュシステムの動作について説明する。
図8は、キャッシュシステムの動作の流れを示すフローチャートである。
キー識別子およびタイムスタンプ情報が指定されたクエリによりデータの読み出しが行われると、アクセス部120は、キャッシュ管理部140に該当するデータのキャッシュ検索を行わせる(ステップ801)。キャッシュ管理部140は、アクセス部120の指示に基づき、まず、クエリで指定されているキー識別子がハッシュ・テーブル410に登録されているか否かを調べる。
<Operation of the cache system>
Next, the operation of the cache system configured by the
FIG. 8 is a flowchart showing the operation flow of the cache system.
When data is read by a query in which a key identifier and time stamp information are specified, the
クエリで指定されたキー識別子がハッシュ・テーブル410に登録されている場合(ステップ802でYes)、次にキャッシュ管理部140は、そのキー識別子に対応付けられたマップ420を探索する(ステップ803)。クエリで指定されたタイムスタンプ情報に基づく条件に合致するレコードがキャッシュされているならば(ステップ804でYes)、キャッシュ管理部140は、そのレコードを読み出してアクセス部120に返す(ステップ805)。
When the key identifier specified by the query is registered in the hash table 410 (Yes in Step 802), the
一方、マップ420を探索した結果、クエリで指定されたタイムスタンプ情報に基づく条件に合致するレコードがキャッシュされていない場合(ステップ804でNo)、すなわちデータオブジェクトが「null」の場合は、キャッシュ管理部140は、その結果をアクセス部120に返す。そして、アクセス部120によるデータベース110の検索結果を取得し(ステップ806)、データベース110から読み出されたレコードをマップ420のマップエントリに対応付けてキャッシュする(ステップ807)。
On the other hand, as a result of searching the
これに対し、クエリで指定されたキー識別子がハッシュ・テーブル410に登録されていない場合(ステップ802でNo)、キャッシュ管理部140は、クエリに合致するレコードがキャッシュされていないことをアクセス部120に通知して、そのキー識別子をハッシュ・テーブル410に登録する(ステップ808)。また、キャッシュ管理部140は、マップ420を作成するための専用のクエリを発行する(ステップ809)。
On the other hand, when the key identifier specified by the query is not registered in the hash table 410 (No in step 802), the
クエリで指定されたキー識別子を持つデータがデータベース110に存在するならば(ステップ810でYes)、そのキー識別子を持つレコードのタイムスタンプ情報等の情報が得られる。この場合、キャッシュ管理部140は、得られた情報に基づいてマップ420を作成する(ステップ811)。次に、キャッシュ管理部140は、アクセス部120によるデータベース110の検索結果を取得し(ステップ812)、データベース110から読み出されたレコードをマップ420のマップエントリに対応付けてキャッシュする(ステップ813)。
If data having the key identifier specified by the query exists in the database 110 (Yes in step 810), information such as time stamp information of the record having the key identifier is obtained. In this case, the
一方、クエリで指定されたキー識別子を持つデータがデータベース110に存在しない場合(ステップ810でNo)、そのキー識別子に対するマップ420を作成することはできない。この場合、キャッシュ管理部140は、ステップ808でハッシュ・テーブル410に登録したキー識別子に対応付けて、データが存在しないことを示す情報をデータ保持部130に保持させる(ステップ814)。
On the other hand, when the data having the key identifier specified by the query does not exist in the database 110 (No in step 810), the
<キャッシュのデータ構造の他の例>
本実施形態によるキャッシュシステムにおけるキャッシュのデータ構造は、キー識別子を登録するハッシュ・テーブル410と、同一のキー識別子を持つレコードを時系列に管理するマップ420との組み合わせで構成される。ここで、ハッシュ・テーブル410やマップ420の構成自体は、データフェッチの内容に応じた変更が可能である。
<Other examples of cache data structure>
The data structure of the cache in the cache system according to the present embodiment is composed of a combination of a hash table 410 for registering key identifiers and a
図9に示すクエリ(SQL文)を考える。このクエリは、キー識別子とタイムスタンプ情報を与えてフェッチするのは図6の例と同じであるが、副照会の中で、主照会で指定のないカラム(IDFR2)をバインドしている。これは、指定したキー識別子を持つレコードのうち、IDFR2値が同じものの中で最新のタイムスタンプを持つレコードのセットを副照会が返すので、このうちCRUD値が「D(削除)」でないものだけを最終的に返す。 Consider the query (SQL statement) shown in FIG. In this query, fetching with a key identifier and time stamp information is the same as in the example of FIG. 6, but a column (IDFR2) not specified in the main query is bound in the subquery. This is because the subquery returns a set of records having the latest time stamp among the records having the specified key identifier among the records having the specified key identifier, and only those whose CRUD value is not “D (delete)”. Finally return.
図10は、このようなクエリに対応するキャッシュのデータ構造の例を示す図である。
図10に示すデータ構造では、ハッシュ・テーブル410とマップ420の間に補助エントリ(Auxiliary entries)430が設けられ、クエリの実行に伴って段階的に指定されるキー識別子が、ハッシュ・テーブル410と補助エントリ430により階層的に登録される。そして、補助エントリ430に登録された最下層のキー識別子に対応付けてマップ420が登録される。
FIG. 10 is a diagram illustrating an example of a data structure of a cache corresponding to such a query.
In the data structure shown in FIG. 10, auxiliary entries (Auxiliary entries) 430 are provided between the hash table 410 and the
図10に示すデータ構造におけるマップを作成するための専用のクエリおよびクエリ結果からデータ構造を生成するコードは、図11のようになる。図11のクエリが実行されると、ハッシュ・テーブル410のエントリから、IDFR2が昇順に並んだ補助エントリ430のリストを経由して、各IDFR2の値ごとにタイムスタンプ順で並んだマップ420が作成される。この状態のキャッシュに対して、所定のキー識別子およびタイムスタンプ情報が指定されたクエリが受け付けられると、例えば、図10の一点鎖線で囲まれたエントリの集合が特定される。そして、必要ならばデータベース110にアクセスして、クエリに対応するデータオブジェクト(entryObj)のレコードを取得した後、CRUD値が「D(削除)」のものを除外したオブジェクトの集合が返される。
FIG. 11 shows a code for generating a data structure from a dedicated query for creating a map in the data structure shown in FIG. 10 and a query result. When the query of FIG. 11 is executed, a
以上、クエリの実行に伴って段階的にキー識別子が指定される場合に適したデータ構造について説明した。クエリの内容によっては、さらに数段階にわたって補助エントリ430を設けることも可能である。
As described above, the data structure suitable for the case where the key identifier is specified step by step as the query is executed has been described. Depending on the contents of the query,
以上、本実施形態について説明したが、本発明の技術的範囲は上記実施形態に記載の範囲には限定されない。例えば、上記実施形態では、クエリがキー識別子とタイムスタンプ情報を指定して発行されるために、マップにおいて各マップエントリをレコードに対応付けるためにタイムスタンプ情報を用いた。これに対し、クエリに対応するレコードを一意に特定できる他の情報を適宜用いてマップを作成しても良い。その他、上記実施形態に、種々の変更または改良を加えたものも、本発明の技術的範囲に含まれることは、特許請求の範囲の記載から明らかである。 As mentioned above, although this embodiment was described, the technical scope of this invention is not limited to the range as described in the said embodiment. For example, in the above embodiment, since the query is issued by designating the key identifier and the time stamp information, the time stamp information is used to associate each map entry with the record in the map. On the other hand, the map may be created by appropriately using other information that can uniquely identify the record corresponding to the query. In addition, it is clear from the description of the scope of the claims that various modifications or improvements added to the above embodiment are also included in the technical scope of the present invention.
100…データベースシステム、110…データベース、120…アクセス部、130…データ保持部、140…キャッシュ管理部、150…マップ作成部、410…ハッシュ・テーブル、420…マップ、421、422…マップエントリ
DESCRIPTION OF
Claims (10)
前記データベースから読み出されたデータをキャッシュする保持部と、
前記保持部にキャッシュされるデータを管理する管理部とを備え、
前記保持部は、
データの前記識別情報を登録するテーブルと、
前記テーブルに登録された前記識別情報に個別に対応付けられ、前記データベースにおける当該識別情報を持つレコードを示すエントリを格納するマップとを備え、
前記管理部は、
前記識別情報およびレコードを指定する情報を含むクエリを受け付けて前記保持部を検索し、
該当するデータがキャッシュされていれば当該データを読み出し、
該当するデータがキャッシュされていなければ、当該データを前記データベースから取得し、前記保持部の前記マップにおける当該クエリにより指定された識別情報およびレコードに対応する前記エントリに関連付けて当該データをキャッシュさせる、システム。 In a database that adds a record of the data with the same identification information every time data is created, updated, or deleted,
A holding unit that caches data read from the database;
A management unit that manages data cached in the holding unit;
The holding part is
A table for registering the identification information of the data;
A map for storing an entry indicating a record having the identification information in the database, individually associated with the identification information registered in the table,
The management unit
Accepting a query including information specifying the identification information and a record, searching the holding unit,
If the corresponding data is cached, read the data,
If the corresponding data is not cached, the data is acquired from the database, and the data is cached in association with the entry corresponding to the identification information and record specified by the query in the map of the holding unit. system.
前記管理部は、前記レコードを指定する情報として前記時間情報が一意に定まる条件を記載したクエリを受け付け、当該条件にしたがって特定される時間情報を持つエントリを、当該クエリにより指定されたレコードを示すエントリとする、請求項1に記載のシステム。 In the entry of the map, time information given to the record when the record is created is recorded,
The management unit accepts a query that describes a condition for uniquely determining the time information as information for designating the record, and indicates an entry having time information specified according to the condition as a record designated by the query The system according to claim 1, wherein the system is an entry.
前記識別情報およびレコードを指定する情報を含むクエリを受け付け、データの前記識別情報を登録するテーブルに対して、当該クエリにより指定された識別情報を検索するステップと、
前記テーブルに前記クエリにより指定された識別情報が存在しない場合、当該識別情報を当該テーブルに登録し、当該識別情報に対応づけて前記データベースにおける当該識別情報を持つレコードを示すエントリを格納するマップを生成するステップと、
前記テーブルに前記クエリにより指定された識別情報が存在する場合、当該識別情報に対応付けられた前記マップの前記エントリに関連付けられたデータがキャッシュされているならば当該データを読み出し、当該エントリに関連付けられたデータがキャッシュされていないならば前記データベースから読み出された当該データを当該エントリに関連付けてキャッシュさせるステップと
を含む、方法。 A database caching method for adding a record of the data with the same identification information every time data is created, updated, or deleted,
Receiving a query including the identification information and information specifying a record, and searching the identification information specified by the query against a table for registering the identification information of data;
When the identification information specified by the query does not exist in the table, the identification information is registered in the table, and a map storing an entry indicating a record having the identification information in the database is associated with the identification information. Generating step;
When the identification information specified by the query exists in the table, if the data associated with the entry of the map associated with the identification information is cached, the data is read and associated with the entry Caching the retrieved data from the database in association with the entry if the data is not cached.
前記識別情報およびレコードを指定する情報を含むクエリを受け付け、データの前記識別情報を登録するテーブルに対して、当該クエリにより指定された識別情報を検索する処理と、
前記テーブルに前記クエリにより指定された識別情報が存在しない場合、当該識別情報を当該テーブルに登録し、当該識別情報に対応づけてデータベースにおける当該識別情報を持つレコードを示すエントリを格納するマップを生成する処理と、
前記テーブルに前記クエリにより指定された識別情報が存在する場合、当該識別情報に対応付けられた前記マップの前記エントリに関連付けられたデータがキャッシュされているならば当該データを読み出し、当該エントリに関連付けられたデータがキャッシュされていないならば前記データベースから読み出された当該データを当該エントリに関連付けてキャッシュさせる処理と
を実行させる、プログラム。 To the computer that controls the database system that adds a record of the data to which the same identification information is assigned every time data is created, updated, or deleted,
A process of accepting a query including information specifying the identification information and a record, and searching the identification information specified by the query against a table that registers the identification information of data;
If the identification information specified by the query does not exist in the table, the identification information is registered in the table, and a map that stores an entry indicating a record having the identification information in the database in association with the identification information is generated. Processing to
When the identification information specified by the query exists in the table, if the data associated with the entry of the map associated with the identification information is cached, the data is read and associated with the entry A program for executing a process of caching the data read from the database in association with the entry if the read data is not cached.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008112945A JP5186270B2 (en) | 2008-04-23 | 2008-04-23 | Database cache system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2008112945A JP5186270B2 (en) | 2008-04-23 | 2008-04-23 | Database cache system |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2009265840A JP2009265840A (en) | 2009-11-12 |
JP5186270B2 true JP5186270B2 (en) | 2013-04-17 |
Family
ID=41391638
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2008112945A Expired - Fee Related JP5186270B2 (en) | 2008-04-23 | 2008-04-23 | Database cache system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP5186270B2 (en) |
Families Citing this family (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5483561B2 (en) | 2010-02-25 | 2014-05-07 | 楽天株式会社 | Storage device, server device, storage system, database device, data providing method, and program |
EP3528141A4 (en) * | 2016-10-17 | 2020-05-13 | Nippon Telegraph And Telephone Corporation | Data processing device and data processing method |
US11514083B2 (en) | 2016-12-22 | 2022-11-29 | Nippon Telegraph And Telephone Corporation | Data processing system and data processing method |
KR102195838B1 (en) | 2019-04-10 | 2020-12-28 | 주식회사 티맥스 소프트 | Method for managing database |
CN113268506B (en) * | 2021-05-24 | 2023-09-26 | 北京京东振世信息技术有限公司 | Query method and device of cache database, electronic equipment and readable storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5499367A (en) * | 1991-11-15 | 1996-03-12 | Oracle Corporation | System for database integrity with multiple logs assigned to client subsets |
US20060218200A1 (en) * | 2005-03-24 | 2006-09-28 | International Business Machines Corporation | Application of log records by storage servers |
-
2008
- 2008-04-23 JP JP2008112945A patent/JP5186270B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
JP2009265840A (en) | 2009-11-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8868595B2 (en) | Enhanced control to users to populate a cache in a database system | |
US7526469B2 (en) | Method and system of database management with shared area | |
US9031923B2 (en) | System for accessing shared data using multiple application servers | |
EP1808780B1 (en) | Determination of database statistics using application logic | |
JP2012174096A (en) | Computer system and data management method | |
WO2012095771A1 (en) | Sparse index table organization | |
JP5186270B2 (en) | Database cache system | |
US20050278398A1 (en) | Storage system | |
JP5160483B2 (en) | Storage system and data migration compatible search system | |
US20090157621A1 (en) | Search device, search method and search program | |
JP2009146084A (en) | Table management device | |
US20080082535A1 (en) | Method and system for automatically generating a communication interface | |
US11327962B1 (en) | Real-time analytical database system for querying data of transactional systems | |
EP1967968B1 (en) | Sharing of database objects | |
JP2001195197A (en) | Digital data sub-system including directory to efficiently provide format information about stored record | |
WO2015105043A1 (en) | Computing system, database management device and computing method | |
JP2004192657A (en) | Information retrieval system, and recording medium recording information retrieval method and program for information retrieval | |
JP4825504B2 (en) | Data registration / retrieval system and data registration / retrieval method | |
US7809766B2 (en) | Writable shared database objects | |
US7685107B2 (en) | Apparatus, system, and method for scanning a partitioned data set | |
US20220245113A1 (en) | Index for multi-level data structures | |
US20230359605A1 (en) | Autonomous Refactoring System for Database | |
CN111444179B (en) | Data processing method, device, storage medium and server | |
JP5673224B2 (en) | Information management apparatus, information management method, and program | |
JP5696280B1 (en) | Term unification system, term unification program, and term unification method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20110119 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20120828 |
|
RD14 | Notification of resignation of power of sub attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7434 Effective date: 20120830 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20121109 |
|
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: 20130108 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20130121 |
|
R150 | Certificate of patent or registration of utility model |
Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20160125 Year of fee payment: 3 |
|
LAPS | Cancellation because of no payment of annual fees |