Management method for data storage space in database, medium and product
Through the segment block storage management method, the problem of too many file handles and too many small files under the large data volume in the database is solved, and efficient storage space management and performance improvement is achieved.
Patent Information
- Application Number
- CN202510421466.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-07-22
AI Technical Summary
In the prior art, the database has too many file handles and too many small files under the large amount of data, resulting in performance degradation and cannot perform fine-grained storage space control.
The segment block storage management method is adopted to set segment spaces in the database table space, all tables allocate data in the segment space, and the storage space is managed in logical organization modes. The size of the zone is flexibly adjusted, and the segment block files are automatically expanded to avoid wasting storage space.
It effectively avoids the impact of too many file handles and too many small files on database performance under large data volume, improves data access efficiency, and reduces waste of storage space.
Smart Images

Figure CN120353797A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of databases, and particularly to a method, medium and product for managing data storage space in a database. Background Art
[0002] In a database system, the current data storage space management mode is as follows: each data table in each database corresponds to a logically large file with a maximum of 32TB. This logical file is divided into multiple actual files according to a fixed size, such as the default 1GB, and stored in the corresponding database directory. Data exists in the form of page blocks in memory. This data storage management mode is called page-based storage space management.
[0003] The logical structure of page-based storage space management in the prior art is as follows:
[0004] (1) Database: Each database object is logically separated from each other.
[0005] (2) Tablespace: A database is logically divided into multiple storage units, called tablespaces. A tablespace is used to group logically related structures together. A database is logically composed of one or more tablespaces.
[0006] (3) Table: It is the basic structure for storing data in a database. A tablespace consists of one or more tables.
[0007] (4) Fork: It refers to storing different parts of relational data. Each table consists of multiple files on disk, and these files are called forks. For example, it is divided into a main fork, an initialization fork, a free space mapping fork, and a visibility mapping fork. These forks work together to enable the database to effectively manage data storage and access, while supporting its complex transaction and concurrency control mechanisms.
[0008] (5) Segment: A segment is allocated to a logical structure, which is a collection of spaces used by a database object. Segments can include table segments, index segments, rollback segments, etc. A table has only one table segment to store data.
[0009] (6) Block (page): It is the smallest logical unit used by a database management system to organize and manage data. A segment has one or more blocks.
[0010] The physical structure of page-based storage space management in the prior art is as follows:
[0011] (1) One database corresponds to one data directory
[0012] (2) Each table under the database has a separate data table subdirectory
[0013] (3) The table data under the data table sub - directory is divided into multiple actual data files according to a fixed size, such as the default 1GB.
[0014] (4) A data file includes one or more pages of the operating system.
[0015] In the page - based storage space management of a database, as the amount of data in each data table increases, the number of files required for underlying data storage will gradually increase. This storage management mode has the following problems: (1) Too many file handles under a large amount of data. In the current mode, virtual file handles can be relied on to solve this problem, but it will affect the performance of the database system. (2) Too many small files will cause random I / O problems in some scenarios, affecting the database performance. (3) High dependence on the file system, and fine - grained control cannot be carried out. Summary of the Invention
[0016] An object of the present invention is to provide a method, medium and product for managing data storage space in a database that can solve any of the above problems.
[0017] A further object of the present invention is to avoid the excessive number of file handles and the excessive number of small files under a large amount of data from affecting the performance of the database through segment - block - based storage management.
[0018] Another further object of the present invention is to flexibly adjust the size of the area according to requirements to avoid waste of storage space.
[0019] Specifically, the present invention provides a method for managing data storage space in a database, including: setting a segment space in the table space of the database, and all tables in the table space allocate data in the segment space; creating a logical segment for each table, and all data of the table is stored on this segment; allocating areas for a segment, and each area is a continuous physical block, so that the data files are allocated and managed for storage space in a logical organization manner of segments, areas, and blocks.
[0020] Optionally, when creating a database, create the corresponding segment space and corresponding files of the database, and store the corresponding files in the segment space as segment - block - type files.
[0021] Optionally, the segment - block - type files include: a preset number of main files, which are used to store table - related metadata and to store user data of the table and other data related to the table.
[0022] Optionally, the segment - block - type files are configured to automatically expand until the disk space is full or reaches the upper limit set by the table space, and will not automatically shrink.
[0023] Optionally, the space occupied by the deleted table in the segment-block file is reserved to form a hole for subsequent reuse by newly extended or newly created tables; and when the hole is not needed, the system function is called to reduce the capacity and release the disk space.
[0024] Optionally, the segment automatically expands in units of extents, and the size of each extent expanded each time is fixed; the storage space is recycled in units of segments by truncating the entire table.
[0025] Optionally, an extent includes four sizes, namely: 64K, 1M, 8M, 64M, and when allocating extents to a segment, the allocation is performed in ascending order of the extent size.
[0026] Optionally, when an extent is expanded, the corresponding extent group is found according to the type of the extent, and then the free extent is found through the bitmap page for expansion to implement extent allocation.
[0027] Optionally, each segment uses a two-dimensional array to record the block number, extent number, and offset in the extent to locate a certain block according to the extent number and offset.
[0028] According to another aspect of the present invention, there is also provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for managing the data storage space in the database as described in any one of the above are implemented.
[0029] According to still another aspect of the present invention, there is also provided a computer program product, including a computer program, characterized in that when the computer program is executed by a processor, the steps of the method for managing the data storage space in the database as described in any one of the above are implemented.
[0030] In the method for managing the data storage space in the database of the present invention, a segment space is set in the tablespace of the database, and all tables in the tablespace allocate data in the segment space; a logical segment is created for each table, and all data of the table is stored on the segment; extents are allocated to a segment, and each extent is a continuous physical block, so that the data file allocates and manages the storage space in a logical organization manner of segments, extents, and blocks. Through the segment-block storage management, it is possible to avoid the excessive number of file handles and the excessive number of small files under a large amount of data from affecting the performance of the database.
[0031] Furthermore, in the method for managing the data storage space in the database of the present invention, the size of the extent can be flexibly adjusted according to requirements to avoid waste of storage space; the segment-block file can be automatically expanded without the need for the user to specify manually, and the segment-block file does not automatically reduce the capacity. When necessary, the system function can be called to reduce the capacity and release the disk space.
[0032] Those skilled in the art will better understand the above and other objects, advantages and features of the present invention from the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings. Brief Description of the Drawings
[0033] Some specific embodiments of the present invention will be described in detail hereinafter with reference to the accompanying drawings in an exemplary but not restrictive manner. The same reference numerals in the drawings denote the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:
[0034] Figure 1 is a schematic flowchart of a method for managing data storage space in a database according to an embodiment of the present invention;
[0035] Figure 2 is a schematic structural diagram of page-based storage space management in the prior art;
[0036] Figure 3 is a schematic structural diagram of segment-block storage management in a method for managing data storage space in a database according to an embodiment of the present invention;
[0037] Figure 4 is a distribution structure diagram of a segment in a method for managing data storage space in a database according to an embodiment of the present invention;
[0038] Figure 5 is a schematic diagram of a computer program product according to an embodiment of the present invention;
[0039] Figure 6 is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention; and
[0040] Figure 7 is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Embodiments
[0041] Those skilled in the art should understand that the embodiments described hereinafter are only a part of the embodiments of the present invention, rather than all of the embodiments of the present invention. These embodiments are intended to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts should still fall within the protection scope of the present invention.
[0042] Note that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in combination with these instruction execution systems, apparatus, or devices.
[0043] The purpose of the method for managing the data storage space in the database of this embodiment is to allocate and manage the storage space in a logical organization manner of segments, extents, and blocks for data files. Through the segment-block storage management, it is possible to avoid the excessive number of file handles and the excessive number of small files under a large amount of data from affecting the performance of the database. Figure 1 is a schematic flowchart of the method for managing the data storage space in the database according to an embodiment of the present invention. As Figure 1 shown, in one embodiment, the method for managing the data storage space in the database generally may include the following steps:
[0044] Step S102, set a segment space in the tablespace of the database, and all tables in this tablespace allocate data in the segment space.
[0045] Step S104, create a logical segment for each table, and all data of this table is stored on this segment.
[0046] Step S106, allocate extents for a segment, and each extent is a continuous physical block, so that the data files are allocated and managed for the storage space in a logical organization manner of segments, extents, and blocks.
[0047] Figure 2 is a schematic structural diagram of page-based storage space management in the prior art. As Figure 2 shown, the logical structure of page-based storage space management in the prior art is as follows:
[0048] (1) Database: Each database object is logically separated from each other.
[0049] (2) Tablespace: The database is logically divided into multiple storage units, called tablespaces. The tablespace is used to put logically related structures together. Logically, the database is composed of one or more tablespaces.
[0050] (3) Table: It is the basic structure for storing data in the database. A tablespace is composed of one or more tables.
[0051] (4) Fork: Refers to different parts of storing relational data. Each table consists of multiple files on disk, and these files are called forks. For example, it can be divided into a main fork, an initialization fork, a free space mapping fork, and a visibility mapping fork. These forks work together to enable the database to effectively manage data storage and access, while supporting its complex transaction and concurrency control mechanisms.
[0052] (5) Segment: A segment is allocated to a logical structure, which is a collection of spaces used by database objects. Segments can include table segments, index segments, rollback segments, etc. A table has only one table segment to store data.
[0053] (6) Block (Page): It is the smallest logical unit used by the database management system to organize and manage data. A segment has one or more blocks.
[0054] The physical structure of page-based storage space management in the prior art is as follows:
[0055] (1) One database corresponds to one data directory
[0056] (2) Each table under the database has a separate data table sub-directory
[0057] (3) The table data under the data table sub-directory is divided into multiple actual data files according to a fixed size, such as the default 1GB.
[0058] (4) One data file includes one or more operating system pages.
[0059] As mentioned above, in the page-based storage space management of the database, when the data volume of each data table increases, the number of files required for the underlying data storage will gradually increase. This storage management mode has the following problems: (1) Too many file handles under large data volumes. In the current mode, virtual handles can be relied on to solve it, but it will affect the performance of the database system. (2) Too many small files will cause random IO problems in some scenarios, affecting the database performance. (3) High dependence on the file system and inability to perform fine-grained control.
[0060] Figure 3 It is a schematic structural diagram of segment-block storage management in the method for managing data storage space in a database according to an embodiment of the present invention. As Figure 3 shown, the logical structure of the segment-block storage management in this embodiment is as follows:
[0061] (1) Database: Each database object is logically separated from each other.
[0062] (2) Tablespace: A database is logically divided into multiple storage units called tablespaces. A tablespace is used to group logically related structures together. Logically, a database consists of one or more tablespaces.
[0063] (3) Segment space: The space where segment data is stored. A tablespace in a database has exactly one segment space. All tables in that tablespace of the database allocate data from this segment space.
[0064] (4) Table / Segment: Each table has a logical segment, and all data of the table is stored on this segment.
[0065] (5) Extent: Each segment contains multiple extents, and each extent is a contiguous physical block. An extent is the smallest unit for expansion or reclamation in the segment-block-based data storage management data mode.
[0066] (6) Block / Page: An extent has one or more blocks, which is the smallest logical unit used by the database management system to organize and manage data.
[0067] The physical structure of the segment-block-based storage management in this embodiment is as follows:
[0068] (1) One database corresponds to one data directory
[0069] (2) One tablespace of a database corresponds to a set of data files.
[0070] (3) Each data file corresponds to one extent, and different extent types are stored in different files.
[0071] (4) One data file includes one or more operating system pages.
[0072] In the solution of this embodiment, a new data storage space management mode called segment-block-based storage space management is provided. In this mode, data files are allocated and managed for storage space in a logical organization manner of segments, extents, and blocks. Therefore, this mode is called segment-block-based storage space management. Each tablespace in a database has a segment space, and all tables in that tablespace of the database allocate data from this segment space. Each table has a logical segment, and all data of this table is stored on this segment. Each segment mounts multiple extents. Each extent is a contiguous physical block, and the size of the extent can be flexibly adjusted according to business requirements to avoid waste of storage space.
[0073] Specifically, there is exactly one segment space in one tablespace of a database. The actual physical storage can be one file or split into multiple files. All tables in that database allocate data from this segment space, so the number of tables has nothing to do with the number of actual physical files.
[0074] The advantages and disadvantages of the page-based storage space management mode previously used by the database and the segment-block-based storage space management mode proposed in this embodiment are briefly described below with an example:
[0075] If a database has thousands or tens of thousands of data tables, and all of them are small-data-volume tables, for the page-based storage space management mode, each table object corresponds to a physical file. Then, when accessing different table objects, it is necessary to open and close physical files multiple times, resulting in huge performance problems. However, for the segment-block-based storage space management mode, since a segment-block-based physical file can store the data of multiple table objects, perhaps only a dozen segment-block-based files are needed to store all small-data-volume tables, greatly reducing the number of physical files and improving the data access performance of the database.
[0076] Regarding the segment management mechanism, it should be noted that when creating a database, the corresponding segment space and files of the database will be created, and the corresponding files will be stored in the segment space as segment-block-based files. The segment-block-based files include: a preset number of main files, files for storing metadata related to tables, and files for storing user data of tables and other data related to tables.
[0077] Specifically, the preset number of main files can be 5, which can be named File 1, File 2, File 3, File 4, and File 5 respectively. File 1 is used to store metadata related to tables, such as the metadata of the table header page and index page. Files 2 to 5 are used to store user data of tables and other data related to tables. Other data related to tables refers to data other than user data, such as additional data for auxiliary quick search and indexing.
[0078] In addition to including a preset number of main files, the segment-block-based files can also include shards of the main files and fork files. Since the size of the main file has certain limitations, a new file can be created as its shard after the size of the main file reaches the upper limit. For example, after the size of File 1 reaches the upper limit, a new file 1.1 can be created as the shard of File 1, which is also used to store some metadata related to tables. Fork files can store other different types of data, such as table data, space management data, etc.
[0079] Regarding the expansion and contraction of segment-block-based files, the segment-block-based files can be automatically expanded without the need for manual specification by the user until the disk space is full or reaches the upper limit limit set for the table space. The segment-block-based files will not be automatically contracted. When some data tables are deleted, the space they occupy in the segment-block-based files is retained, that is, there will be holes in the segment-block-based files, and the disk space is not released. These holes will be reused by newly expanded or created tables later.
[0080] All the data of an object managed by segment block - based storage management is called a segment. All the data of a segment is stored in 5 files in the segment space in units of extents, and they are not contiguous. Simply put, one segment corresponds to one object, such as a data table or an index, and one object has a logically corresponding segment.
[0081] For segment expansion / table expansion and segment recycling / table recycling, segments expand automatically in units of extents, adding new extents. The size of each expanded extent is fixed. As shown in the range of extent numbers in Table 1, before a segment expands, the size of the first 16 extents is 64K, the size of the 17th to 143rd extents is 1M, and so on. It is not possible to directly recycle a single extent. Instead, the storage space can be recycled at the segment level by truncating the entire table.
[0082] Group number Zone size Number of blocks in each zone Zone number range Total number of blocks Total size 1 64K 8 [1,16] 128 1M 2 1M 128 [17,143] 16K 128M 3 8M 1024 [144,255] 128K 1G 4 64M 8192 [256,…] … …
[0083] Table 1
[0084] Regarding the extent management mechanism, it should be noted that currently four sizes of extents are supported, namely 64K, 1M, 8M, and 64M. Taking a block size of 8K as an example, the corresponding relationship between the number of each type of extent and the number of blocks is shown in Table 1. From Table 1, it can be seen that there are 16 extents with a size of 64K, 127 extents with a size of 1M, 112 extents with a size of 8M, and an arbitrary number of extents with a size of 64M. When allocating extents, they are allocated in ascending order of extent size. Therefore, for a segment, the first 16 extents have a size of 64K, the 17th to 143rd extents have a size of 1M, the 144th to 255th extents have a size of 8M, and the extent numbers of 64M start from 256 and can be infinite.
[0085] Figure 4 It is a distribution structure diagram of a segment in the method for managing data storage space in a database according to an embodiment of the present invention. From Figure 4 it can be seen that the extent distribution in a segment is fixed. The extents with a size of 64K are stored in File 2, with a total of 16 64K extents. The extents with a size of 1M are stored in File 3, with a total of 127 1M extents. The extents with a size of 8M are stored in File 4, with a total of 112 8M extents. The extents with a size of 64M are stored in File 5, and the number can be infinite until the disk limit. File 1 is mainly used to store table - related metadata. From Figure 4 it can be seen that the data of a table stored in segment block - based storage is scattered in 5 large files and is not contiguous. While in page - based storage management, the data of a table is stored in one file.
[0086] For extent expansion and extent recycling, during extent expansion, according to the extent type, find the corresponding extent group, and then find free extents through bitmap pages for allocation and expansion. In fact, it is extent allocation. When some data is deleted, the space it occupies in the segment-block file will be retained, that is, there will be some holes in the segment-block file, and the disk space is not released, nor can a certain extent be directly recycled. The usage of extents is managed through the bitmap pages in the extent group hierarchy, and these extents will be reused by newly extended or created tables later. That is to say, segment-block storage does not automatically shrink. If the user determines that these holes are not needed, they can manually call system functions to perform shrinking and release disk space.
[0087] For the mapping between extent numbers and page numbers, segment-block storage expands in terms of extents, while the basic unit for operation in memory is the blocks within an extent. Therefore, it is necessary to maintain the relationship between block numbers, extent numbers, and the offsets within the extent. Each segment uses a two-dimensional array to record the block numbers, extent numbers, and offsets within the extent, facilitating the positioning of a certain block from the extent number and the offset within the extent.
[0088] In the solution of this embodiment, a segment space is set in the tablespace of the database, and all tables in this tablespace allocate data in the segment space; a logical segment is created for each table, and all data of this table is stored on this segment; extents are allocated for a segment, and each extent is a continuous physical block, so that the data file allocates and manages storage space in a logical organization manner of segments, extents, and blocks. Through segment-block storage management, it is possible to avoid the excessive number of file handles and the excessive number of small files under a large amount of data from affecting the performance of the database.
[0089] The size of the extent can be flexibly adjusted according to requirements to avoid waste of storage space; the segment-block file can be automatically expanded without the need for the user to specify manually, and the segment-block file does not automatically shrink. When necessary, it can be shrunk by calling system functions to release disk space.
[0090] The flowcharts provided in the above embodiments are not intended to indicate that the operations of the method will be executed in any specific order, or that all operations of the method are included in every case. In addition, the method may include additional operations. Within the scope of the technical ideas provided by the method in the above embodiments, additional changes can be made to the above method.
[0091] This embodiment also provides a computer program product, a computer-readable storage medium, and a computer device. Figure 5 It is a schematic diagram of a computer program product 500 according to an embodiment of the present invention. Figure 6 It is a schematic diagram of a computer-readable storage medium 300 according to an embodiment of the present invention. Figure 7 It is a schematic diagram of a computer device 400 according to an embodiment of the present invention.
[0092] The computer program product 500 includes a computer program 310, which when executed by a processor 410 implements the steps of the method for managing the data storage space in the database in any of the above. The computer-readable storage medium 300 stores the above computer program 310, and when the computer program 310 is executed by the processor 410, it implements the steps of the method for managing the data storage space in the database in any of the above embodiments. The computer device 400 may include a memory 420, a processor 410, and a computer program 310 stored on the memory 420 and running on the processor 410.
[0093] The computer program 310 for performing the operations of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, configuration data of an integrated circuit, or source code or object code written in any combination of one or more programming languages and procedural programming languages.
[0094] The computer program 310 may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider via the Internet).
[0095] In some embodiments, to perform various aspects of the present invention, an electronic circuit, including for example a programmable logic circuit, a field-programmable gate array (FPGA), or a programmable logic array (PLA), may execute computer-readable program instructions by utilizing the state information of the computer-readable program instructions to personalize the electronic circuit.
[0096] For the description of this embodiment, the computer program product 500 is a related product containing the computer program 310. For the description of this embodiment, the computer-readable storage medium 300 is a tangible device capable of retaining and storing the computer program 310, which may be any device that can contain, store, communicate, propagate, or transmit the computer program 310 for use by an instruction execution system, apparatus, or device or in conjunction with these instruction execution systems, apparatus, or devices.
[0097] More specific examples (nonexhaustive list) of the computer-readable storage medium 300 include the following: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD), memory stick, floppy disk, mechanically encoded device, and any suitable combination of the foregoing.
[0098] The computer device 400 may include a memory 420, a processor 410, and a computer program 310 stored on the memory 420 and running on the processor 410. When the processor 410 executes the computer program 310, the steps of the method for managing the data storage space in the database of any of the foregoing embodiments are implemented.
[0099] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in conjunction with these instruction execution systems, apparatus, or devices.
[0100] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system.
[0101] The computer device 400 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smart phone. In some examples, the computer device 400 can be a cloud computing node. The computer device 400 can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 400 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0102] The computer device 400 may include a processor 410 adapted to execute stored instructions and a memory 420 that provides temporary storage space for the operation of the instructions during operation. The processor 410 may be a single-core processor, a multi-core processor, a computing cluster, or any number of other configurations. The memory 420 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.
[0103] The processor 410 may be connected through a system interconnect (such as PCI, PCI-Express, etc.) to an I / O interface (input / output interface) adapted to connect the computer device 400 to one or more I / O devices (input / output devices). The I / O devices may include, for example, a keyboard and a pointing device, where the pointing device may include a touchpad or a touch screen, etc. The I / O devices may be built-in components of the computer device 400 or may be devices externally connected to the computing device.
[0104] The processor 410 may also be linked through a system interconnect to a display interface adapted to connect the computer device 400 to a display device. The display device may include a display screen as a built-in component of the computer device 400. The display device may also include a computer monitor, a television, a projector, etc. externally connected to the computer device 400. In addition, a network interface controller (NIC) may be adapted to connect the computer device 400 to a network through a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network may be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices may be connected to the computing device through the network.
[0105] At this point, those skilled in the art should recognize that although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived from the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and determined to cover all these other variations or modifications.
Claims
1. A method for managing data storage space in a database, comprising: Setting a segment space in the tablespace of the database, and allocating data for all tables in the tablespace in the segment space; Creating a logically segment for each of the tables, and storing all data of the table on the segment; Allocating extents to a segment, each extent being a continuous physical block, so that the data file allocates and manages the storage space in a logical organization manner of segment, extent and block.
2. The management method according to claim 1, wherein, When creating the database, creating the corresponding segment space and corresponding files of the database, and Storing the corresponding files in the segment space as segment block files.
3. The management method according to claim 2, wherein, The segment block file includes: a preset number of main files, which are used to store metadata related to the table and to store user data of the table and other data related to the table.
4. The management method according to claim 3, wherein, The segment block file is configured to automatically expand until the disk space is full or reaches the upper limit set by the tablespace, and will not automatically shrink.
5. The management method according to claim 4, wherein, The space occupied by the deleted table in the segment block file is reserved to form a hole for subsequent reuse by newly extended or newly created tables; and When the hole is not needed, the disk space is released by calling a system function for shrinking.
6. The management method according to claim 5, wherein, The segment automatically expands in units of extents, and the size of each expanded extent is fixed; The storage space is reclaimed in units of segments by truncating the entire table.
7. The management method according to claim 6, wherein, The extent includes four sizes, namely: 64K, 1M, 8M, 64M, and When allocating extents to a segment, the extents are allocated in ascending order of size.
8. The management method according to claim 7, wherein, When the extent expands, find the corresponding extent group according to the type of the extent, and then find the free extent through the bitmap page for expansion to achieve extent allocation.
9. The management method according to claim 1, wherein, Each segment uses a two-dimensional array to record the block number, extent number and offset in the extent, so as to locate a certain block according to the extent number and the offset.
10. A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for managing data storage space in the database according to any one of claims 1 to 9 are implemented.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, the steps of the method for managing data storage space in the database according to any one of claims 1 to 9 are implemented.