A kind of database storage method of ranks mixing
Technical field
The present invention relates to a kind of data database storing technology, particularly relate to a kind of ranks mixing storage means of application oriented storage magnanimity unstructured data object.
Background technology
At present, the data of data base management system (DBMS) management present with the bivariate table form of row, column, and row correspond to record, and row correspond to the field of record.
Traditional line data storehouse, when storing data, is written to the data value of a line in internal memory or hard disk as an one dimension character string, if therefore will inquire about certain field value of certain record, then needs to read whole piece record.But for inquiry intensive applications, a part of field value of record is often only used in great majority inquiry.Adopt row memory technology, system can be caused in the reading of data and storage to there is following weak point, performance cannot meet the demand of application.
First, although only use a part of field of record, but existing row memory technology makes system whole piece record all must be read in buffer memory, data reading speed is so not only caused to reduce, I/O expense is excessive, and loads the spatial cache that unwanted field wastes preciousness, reduces cache hit rate, make follow-up data processing delay, the performance of system is affected.
Secondly, the field of record can be divided into the conventional field of inquiry and non-common field, if be placed on cheap apparatus by non-common field, can reduce carrying cost.But existing row memory technology feature determines conventional field and the field that is of little use is Coutinuous store on disk, occupies same storage resources.This is unfavorable for the reasonable distribution of resource apparatus.
Columnar database appear at the above deficiency that compensate for line data storehouse to a certain extent.Its feature is stored by row by record.But this also causes it to there are some problems when inquiring about application.Such as, if the demand of inquiry application carries out query count according to the value of a certain row, obtain front some the record numbers that the degree of correlation is the highest, and return the value of some appointment row (field) of these some records.Columnar database is when realizing this demand, store by row because record, so after the value arranged according to certain is inquired about and is obtained relative recording numbering, the value of other appointment row recorded can not be obtained immediately, but also need first to search these appointment row, and then record is searched from these appointment row, read out the respective value of record.This search procedure reduces the performance of inquiry.
Summary of the invention
For solving above-mentioned middle Problems existing and defect, the invention provides a kind of database storage method of ranks mixing of application oriented storage magnanimity unstructured data object.Described technical scheme is as follows:
A database storage method for ranks mixing, comprising:
Create the amount of physical memory of table and table correspondence, establish the corresponding relation of row and amount of physical memory according to application demand;
In table, insert record, and divide into groups by the corresponding relation of row and amount of physical memory;
The train value of record is written in corresponding amount of physical memory as row.
The beneficial effect of technical scheme provided by the invention is:
Be efficiently avoid by ranks mixing storage means provided by the invention and entirely show inquiry, reduce I/O expense, improve the speed of digital independent and the query performance of full-text database.
Accompanying drawing explanation
Fig. 1 is the database storage method process flow diagram of ranks mixing;
Fig. 2 is the storage architecture design drawing of table.
Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail:
Present embodiments provide the database storage method of a kind of ranks mixing, wherein,
See Fig. 1, the method comprises the following steps:
Step 10 creates the amount of physical memory of table and table correspondence, establishes the corresponding relation of row and storage space according to application demand;
Step 20 inserts record in table, and divides into groups by the corresponding relation of row and amount of physical memory;
The train value of record is written in corresponding amount of physical memory as row by step 30.
Above-mentioned steps 10 establishment table comprises the title of establishment table, field and the amount of physical memory needed for allocation table, and establish the corresponding relation of row and amount of physical memory, above-mentioned row are field.In the present embodiment, the corresponding one or more amount of physical memory (as shown in Figure 2) of each table, if do not do special appointment during establishment table, system will distribute the amount of physical memory of an acquiescence automatically.After creating table, also can assess requisite space according to the dynamic change of data, application creates new storage space.For the field in table, it can be specified when establishment table to be stored in which amount of physical memory, row (field) higher for frequency of utilization can be continuously stored in same storage space, to improve the efficiency of digital independent like this.
In above-mentioned steps 20, when inserting record in table, be the identification number that record establishment one is unique in the table, and by record by row (field) cutting; According to the mapping table of field and amount of physical memory, divided into groups by train value (field value), the train value (field value) that correspond to the row of same amount of physical memory is divided into same group, and each group can be considered as a row vector.
Above-mentioned steps 30, after train value (field value) grouping by recording, using train value group as a row vector (an one dimension character string), is written to corresponding amount of physical memory.Due to what undertaken storing in order by record identify number during data in amount of physical memory, therefore the particular location of inserting line vector is also determined according to the size of record identify number.If this corresponding amount of physical memory is full, cannot perform insertion, then application opens up a new amount of physical memory to store, and the mapping table of more newer field and storage space.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.