CN111897821B - Automatic table partitioning method and related device for PG database - Google Patents

Automatic table partitioning method and related device for PG database Download PDF

Info

Publication number
CN111897821B
CN111897821B CN202010879807.2A CN202010879807A CN111897821B CN 111897821 B CN111897821 B CN 111897821B CN 202010879807 A CN202010879807 A CN 202010879807A CN 111897821 B CN111897821 B CN 111897821B
Authority
CN
China
Prior art keywords
database
partition
partitioning
version number
pathman
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.)
Active
Application number
CN202010879807.2A
Other languages
Chinese (zh)
Other versions
CN111897821A (en
Inventor
孙志云
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.)
Inspur Power Commercial Systems Co Ltd
Original Assignee
Inspur Power Commercial Systems Co 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 Inspur Power Commercial Systems Co Ltd filed Critical Inspur Power Commercial Systems Co Ltd
Priority to CN202010879807.2A priority Critical patent/CN111897821B/en
Publication of CN111897821A publication Critical patent/CN111897821A/en
Application granted granted Critical
Publication of CN111897821B publication Critical patent/CN111897821B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an automatic table partitioning method of a PG database, which comprises the steps of obtaining partitioning instructions of the PG database; acquiring the version number of the PG database according to the partition instruction of the PG database; downloading and installing the pathman plug-in when the version number is lower than V10; calling a pathman plug-in to perform table partitioning on the PG database; and when the version number is not lower than V10, carrying out table partitioning on the PG database through a partitioning functional module preset by the PG database. When the version of the PG database is lower than V10, the pathman plug-in is automatically downloaded and installed, and the table partition of the PG database is completed based on the pathman plug-in; when the version of the PG database is not lower than V10, the table partition of the PG database is completed based on the partition function module of the PG database. The invention also provides a device, equipment and a storage medium, which also have the beneficial effects.

Description

Automatic table partitioning method and related device for PG database
Technical Field
The present invention relates to the field of database technologies, and in particular, to an automated table partitioning method for a PG database, an automated table partitioning apparatus for a PG database, an automated table partitioning device for a PG database, and a computer readable storage medium.
Background
The PostgreSQL is an object-relational database management system (ORDBMS) of free software with very complete characteristics, is also commonly called as FG database, is a very excellent open source database, has rich functions, is an open source database which completely surpasses MySQL in function, is not worse than MysQL in performance, is a process architecture like Oracle, and can better play the performance of multiple CPUs. As the use of PG databases has become more common, optimization efforts for such databases have also been continuously evolving. Where partitioning table setting is an important aspect of database optimization. The implementation of the table partitions varies greatly due to the different versions of the PG database. Pgv8.X and the most commonly used pgv9.X versions today do not implement built-in partitions, and are difficult to implement in table partitions. Pgv10.X and the upper version are increasingly sophisticated in implementing table partitioning. Currently, in testing and using PG databases, it is still an ongoing task to manually create table partitions.
In the prior art, the table partitions of the PG database are created manually according to different database versions. For the version below PGV10.X, creating according to the table partition supported by the database, namely, creating a sub-table in a inheritance table mode to realize the partition; and then, the data distribution is realized by creating a trigger, so that the data is inserted into the main table, and the data can be automatically distributed into the sub-partition table. For pgv10.X and above versions, because the database itself implements support for built-in partitions, no triggers need to be created to implement data distribution, the partition master table is directly created, and then the partition table is created.
In the prior art, the table partitioning is manually performed, the version table partitioning below V10 is complex in operation and long in time consumption, and the performance improvement after optimization is not obvious; in the version V10 or above, although the built-in table partition is realized, the operation is simplified compared with the database of the lower version, but when the database test tuning is performed, the database is frequently operated, and the partition table creation is completed manually one by one, which is also very labor-consuming. And the efficiency is low. How to automatically identify different versions of a database and automatically complete the creation of a table partition is an urgent problem to be solved by those skilled in the art.
Disclosure of Invention
The invention aims to provide an automatic table partitioning method of a PG database, which can complete automatic table partitioning for different versions of the PG database; it is another object of the present invention to provide an automated table partitioning apparatus for a variety of PG databases, an automated table partitioning device for a PG database, and a computer-readable storage medium, which can perform an automated table partitioning for different versions of a PG database.
In order to solve the above technical problems, the present invention provides an automated table partitioning method for a PG database, comprising:
acquiring a PG database partition instruction;
acquiring the version number of the PG database according to the PG database partition instruction;
downloading and installing the pathman plugin when the version number is lower than V10;
calling the pathman plug-in to perform table partitioning on the PG database;
and when the version number is not lower than V10, performing table partitioning on the PG database through a partitioning functional module preset by the PG database.
Optionally, before the step of obtaining the PG database partitioning instruction, the method further comprises:
acquiring installation completion information of the PG database;
and establishing a main table of the PG database according to the installation completion information.
Optionally, the acquiring the PG database partitioning instruction comprises:
acquiring a selection instruction corresponding to a target main table in the main table;
and generating a PG database partition instruction corresponding to the target main table according to the selection instruction.
Optionally, the calling the pathman plugin to perform table partitioning on the PG database includes:
acquiring configuration information of a sub-partition table;
and calling the pathman plug-in and establishing a sub-partition table corresponding to the configuration information.
Optionally, when the version number is not lower than V10, performing table partitioning on the PG database by using a partition function module preset in the PG database includes:
when the version number is not lower than V10, acquiring configuration information of a sub-partition table;
and calling a partition function module preset by the PG database, and establishing a sub-partition table corresponding to the configuration information.
The invention also provides an automatic table partitioning device of the PG database, which comprises:
the instruction acquisition module: the method comprises the steps of obtaining a PG database partition instruction;
version number acquisition module: the method comprises the steps of obtaining a version number of a PG database according to a PG database partition instruction;
pathman plug-in module: downloading and installing the pathman plugin when the version number is lower than V10;
low version partition module: the pathman plug-in is used for calling the pathman plug-in to conduct table partitioning on the PG database;
high version partition module: and when the version number is not lower than V10, performing table partitioning on the PG database through a partitioning functional module preset by the PG database.
Optionally, the method further comprises:
PG database module: the method comprises the steps of obtaining installation completion information of a PG database;
and a main table module: and the main table is used for establishing the PG database according to the installation completion information.
Optionally, the instruction acquisition module includes:
selecting an instruction unit: the selection instruction is used for acquiring a target main table corresponding to the main table;
an instruction acquisition unit: and the PG database partition instruction is used for generating the PG database partition instruction corresponding to the target main table according to the selection instruction.
The invention also provides an automated table partitioning device of the PG database, which comprises:
a memory: for storing a computer program;
a processor: steps for implementing an automated table partitioning method of a PG database as set forth in any one of the preceding claims when executing the computer program.
The present invention also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the automated table partitioning method of a PG database as set forth in any one of the above.
The invention provides an automatic table partitioning method of a PG database, which comprises the steps of obtaining partitioning instructions of the PG database; acquiring the version number of the PG database according to the partition instruction of the PG database; downloading and installing the pathman plug-in when the version number is lower than V10; calling a pathman plug-in to perform table partitioning on the PG database; and when the version number is not lower than V10, carrying out table partitioning on the PG database through a partitioning functional module preset by the PG database. When partitioning the PG database, the PG database is judged to be a version below V10 or a version above V10 according to the version number of the PG database. When the version of the PG database is lower than V10, the pathman plug-in is automatically downloaded and installed, and the table partition of the PG database is completed based on the pathman plug-in; when the version of the PG database is not lower than V10, the table partition of the PG database is completed based on the partition function module of the PG database, so that automatic table partition can be completed for different versions of the PG database.
The invention also provides an automatic table partitioning device of the PG database, automatic table partitioning equipment of the PG database and a computer readable storage medium, which have the same beneficial effects and are not repeated herein.
Drawings
For a clearer description of embodiments of the invention or of the prior art, the drawings that are used in the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description below are only some embodiments of the invention, and that other drawings can be obtained from them without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of an automated table partitioning method for a PG database according to an embodiment of the present invention;
FIG. 2 is a flowchart of an automated table partitioning method for a specific PG database according to an embodiment of the present invention;
FIG. 3 is a block diagram illustrating an automated table partitioning apparatus for a PG database according to an embodiment of the present invention;
fig. 4 is a block diagram of an automated table partitioning apparatus for a PG database according to an embodiment of the present invention.
Detailed Description
The core of the invention is to provide an automatic table partitioning method of a PG database. In the prior art, the table partitions of the PG database are created manually according to different database versions. For the version below PGV10.X, creating according to the table partition supported by the database, namely, creating a sub-table in a inheritance table mode to realize the partition; and then, the data distribution is realized by creating a trigger, so that the data is inserted into the main table, and the data can be automatically distributed into the sub-partition table. For pgv10.X and above versions, because the database itself implements support for built-in partitions, no triggers need to be created to implement data distribution, the partition master table is created directly, and then the partition table is created.
In the prior art, the table partitioning is manually performed, the version table partitioning below V10 is complex in operation and long in time consumption, and the performance improvement after optimization is not obvious; in the version V10 or above, although the built-in table partition is realized, the operation is simplified compared with the database of the lower version, but when the database test tuning is performed, the database is frequently operated, and the partition table creation is completed manually one by one, which is also very labor-consuming. And the efficiency is low.
The invention provides an automatic table partitioning method of a PG database, which comprises the steps of obtaining partitioning instructions of the PG database; acquiring the version number of the PG database according to the partition instruction of the PG database; downloading and installing the pathman plug-in when the version number is lower than V10; calling a pathman plug-in to perform table partitioning on the PG database; and when the version number is not lower than V10, carrying out table partitioning on the PG database through a partitioning functional module preset by the PG database. When partitioning the PG database, the PG database is judged to be a version below V10 or a version above V10 according to the version number of the PG database. When the version of the PG database is lower than V10, the pathman plug-in is automatically downloaded and installed, and the table partition of the PG database is completed based on the pathman plug-in; when the version of the PG database is not lower than V10, the table partition of the PG database is completed based on the partition function module of the PG database, so that automatic table partition can be completed for different versions of the PG database.
In order to better understand the aspects of the present invention, the present invention will be described in further detail with reference to the accompanying drawings and detailed description. It will be apparent that the described embodiments are only some, but not all, embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Referring to fig. 1, fig. 1 is a flowchart of an automated table partitioning method for a PG database according to an embodiment of the present invention.
Referring to fig. 1, in an embodiment of the present invention, an automated table partitioning method for a PG database includes:
s101: and acquiring the PG database partition instruction.
The specific form of the PG database partitioning instruction can be set according to the actual situation, and is not limited herein, so long as the server can execute the following steps when receiving the PG database partitioning instruction.
Specifically, in the embodiment of the present invention, an auto-sh script may be pre-packaged, and in this step, this step may be performed by the auto-sh script.
S102: and acquiring the version number of the PG database according to the PG database partition instruction.
In this step, the version number of the installed PG fetching database, which is usually expressed in the form of VX, is checked according to the PG database partition instruction acquired in S101, where X is expressed as a specific number.
Specifically, the step can obtain the PG database version number of the current linux system through psql-version in the auto-sh script.
S103: when the version number is below V10, the pathman plug-in is downloaded and installed.
When the version number of the PG database is lower than V10, this means that the PG database does not realize built-in partitioning, that is, the table partitioning function cannot be realized through the PG database itself. Thus, in this step, the pathman plug-in is automatically downloaded, compiled, and set up to the environment variables to facilitate invocation of the pathman plug-in.
Specifically, in the embodiment of the present invention, an extension. Sh script may be pre-packaged. When the step is needed to be executed, an extension.sh script is automatically executed, and the download and the installation of the pathman plug-in are realized through the extension.sh script.
S104: invoking the pathman plugin to perform table partitioning on the PG database.
In this step, after the pathman plugin is installed, the pathman plugin may be invoked to tablepartition the PG database with version below V10. For details of the pathman plug-in, reference is made to the prior art, and no further description is given here. In this step, table partitioning of the low-version PG database is specifically implemented through pathman plug-in.
S105: and when the version number is not lower than V10, carrying out table partitioning on the PG database through a partitioning functional module preset by the PG database.
When the version number of the PG database is not lower than V10, the PG database realizes built-in partition, namely, the function of table partition can be realized through the PG database. Therefore, in this step, the table partition is performed on the PG database by using the partition function module preset in the PG database of the high version. Specifically, in the embodiment of the present invention, an installed. Sh script is usually pre-packaged. When the step is executed, the sampled sh script can be automatically executed, and the table partition is carried out on the PG database through the sampled sh script based on a partition functional module preset by the PG database.
The automatic table partitioning method of the PG database provided by the embodiment of the invention comprises the steps of obtaining a partitioning instruction of the PG database; acquiring the version number of the PG database according to the partition instruction of the PG database; downloading and installing the pathman plug-in when the version number is lower than V10; calling a pathman plug-in to perform table partitioning on the PG database; and when the version number is not lower than V10, carrying out table partitioning on the PG database through a partitioning functional module preset by the PG database. When partitioning the PG database, the PG database is judged to be a version below V10 or a version above V10 according to the version number of the PG database. When the version of the PG database is lower than V10, the pathman plug-in is automatically downloaded and installed, and the table partition of the PG database is completed based on the pathman plug-in; when the version of the PG database is not lower than V10, the table partition of the PG database is completed based on the partition function module of the PG database, so that automatic table partition can be completed for different versions of the PG database.
The specific content of the automatic table partitioning method for the PG database provided by the present invention will be described in detail in the following embodiments of the present invention.
Referring to fig. 2, fig. 2 is a flowchart of an automated table partitioning method for a specific PG database according to an embodiment of the present invention.
Referring to fig. 2, in an embodiment of the present invention, an automated table partitioning method for a PG database includes:
s201: and acquiring installation completion information of the PG database.
The specific form of the installation completion information may be set according to the actual situation, and is not particularly limited herein. In the embodiment of the present invention, the installation completion information is typically information generated when the PG database is just completed. In this step, when the installation completion information of the PG database is acquired, it generally means that the PG database has just been installed.
S202: and establishing a main table of the PG database according to the installation completion information.
In this step, a master table of the PG database is specifically built according to the installation completion information, and the number of the master tables may be one or more, which is not specifically limited in the embodiment of the present invention.
S203: and acquiring a selection instruction of a target main table in the corresponding main table.
In this step, the user typically needs to select a target master table from the master tables established in the previous step, where the target master table needs to be partitioned. Correspondingly, in this step, the server acquires a selection instruction corresponding to the target main table.
S204: and generating a PG database partition instruction corresponding to the target main table according to the selection instruction.
In this step, a PG database partitioning instruction corresponding to the target main table is specifically generated according to the selection instruction, so that in this step, table partitioning is performed on the target main table according to the PG database partitioning instruction.
Specifically, in the embodiment of the present invention, it may be specifically determined whether the PG database is being installed by rpm-qa|grep postgresql in the auto. Sh script, and the above-described S201 to S204 are performed to finally generate the PG database partition instruction.
S205: and acquiring the version number of the PG database according to the PG database partition instruction.
S206: when the version number is below V10, the pathman plug-in is downloaded and installed.
The above S205 to S206 are substantially identical to S102 to S103 in the above embodiment of the present invention, and the detailed description will be made with reference to the above embodiment of the present invention, and will not be repeated here.
S207: configuration information of the sub-partition table is obtained.
In this step, typically, when the extension. Sh script is executed, the user is allowed to input configuration information of the sub-partition table, such as a table name, an ID field name, the number, etc., so as to generate a corresponding sub-partition table according to the configuration information in a subsequent step.
S208: and calling the pathman plug-in, and establishing a sub-partition table corresponding to the configuration information.
In this step, a corresponding sub-partition table is established according to the configuration information through pathman plug-in, so as to complete the table partition of the PG database. The specific implementation of the pathman plug-in may refer to the prior art, and will not be described in detail herein.
S209: and when the version number is not lower than V10, acquiring configuration information of the sub-partition table.
In this step, typically, when the structured. Sh script is executed, the user is allowed to input configuration information of the sub-partition table, such as a table name, an ID field name, the number, etc., so as to generate a corresponding sub-partition table according to the configuration information in a subsequent step. The rest of this step is described in detail in S105 in the above embodiment of the present invention, and will not be described herein.
S210: and calling a partition function module preset in the PG database, and establishing a sub-partition table corresponding to the configuration information.
In this step, a corresponding sub-partition table is generally built according to the configuration information through an isolated.sh script, so as to complete the table partition of the PG database. The specific implementation of the partition function module may refer to the prior art, and will not be described herein.
When partitioning the PG database, the automatic table partitioning method for the PG database provided by the embodiment of the invention judges whether the PG database is in a version below V10 or in a version above V10 according to the version number of the PG database. When the version of the PG database is lower than V10, the pathman plug-in is automatically downloaded and installed, and the table partition of the PG database is completed based on the pathman plug-in; when the version of the PG database is not lower than V10, the table partition of the PG database is completed based on the partition function module of the PG database, so that automatic table partition can be completed for different versions of the PG database.
The following describes an automated table partitioning apparatus for a PG database according to an embodiment of the present invention, where the automated table partitioning apparatus for the PG database described below and the automated table partitioning method for the PG database described above may be referred to correspondingly.
Referring to fig. 3, fig. 3 is a block diagram illustrating an automated table partitioning apparatus for a PG database according to an embodiment of the present invention.
Referring to fig. 3, in an embodiment of the present invention, an automated table partitioning apparatus of a PG database may comprise:
instruction fetch module 100: for obtaining PG database partition instructions.
Version number acquisition module 200: and the method is used for acquiring the version number of the PG database according to the PG database partition instruction.
pathman plug-in module 300: when the version number is below V10, the pathman plug-in is downloaded and installed.
Low version partition module 400: and the pathman plug-in is used for calling the pathman plug-in to conduct table partitioning on the PG database.
High version partition module 500: and when the version number is not lower than V10, performing table partitioning on the PG database through a partitioning functional module preset by the PG database.
Preferably, in the embodiment of the present invention, the method may further include:
PG database module: and the installation completion information of the PG database is acquired.
And a main table module: and the main table is used for establishing the PG database according to the installation completion information.
Preferably, in an embodiment of the present invention, the instruction fetch module 100 may include:
selecting an instruction unit: the selection instruction is used for acquiring a target main table corresponding to the main table;
an instruction acquisition unit: and the PG database partition instruction is used for generating the PG database partition instruction corresponding to the target main table according to the selection instruction.
Preferably, in an embodiment of the present invention, the low-version partition module 400 may include:
first configuration information element: and the configuration information is used for acquiring the sub-partition table.
A first partitioning unit: and the pathman plug-in is used for calling the pathman plug-in and establishing a sub-partition table corresponding to the configuration information.
Preferably, in an embodiment of the present invention, the high-version partition module 500 may include:
second configuration information element: and when the version number is not lower than V10, acquiring configuration information of the sub-partition table.
A second dividing unit: and the partitioning function module is used for calling the preset partitioning function module of the PG database and establishing a sub-partitioning table corresponding to the configuration information.
The automatic table partitioning apparatus of the PG database of the present embodiment is used for implementing the foregoing automatic table partitioning method of the PG database, so that the detailed description of the automatic table partitioning apparatus of the PG database can be found in the foregoing example portions of the automatic table partitioning method of the PG database, for example, the instruction acquisition module 100, the version number acquisition module 200, the pathman plug-in module 300, the low version partitioning module 400, and the high version partitioning module 500 are respectively used for implementing steps S101 to S105 in the page buffer reclaiming method, and therefore, the detailed description of the embodiments of each portion will be omitted herein.
The following describes an automatic table partitioning apparatus of a PG database according to an embodiment of the present invention, where the automatic table partitioning apparatus of the PG database described below and the automatic table partitioning method of the PG database described above and the automatic table partitioning device of the PG database may refer to each other correspondingly.
Referring to fig. 4, fig. 4 is a block diagram illustrating an automated table partitioning apparatus for a PG database according to an embodiment of the present invention.
Referring to fig. 4, the automated table partitioning apparatus of the PG database may comprise a processor 11 and a memory 12.
The memory 12 is used for storing a computer program; the processor 11 is configured to implement the automated table partitioning method of the PG database described in the above embodiment of the present invention when executing the computer program.
The processor 11 in the automated table partitioning apparatus for a PG database of the present embodiment is used to install the automated table partitioning apparatus for a PG database described in the above embodiment of the present invention, and the processor 11 in combination with the memory 12 may implement the automated table partitioning method for a PG database described in any one of the above embodiments of the present invention. Therefore, the specific embodiments in the automated table partitioning apparatus based on the PG database can be found in the foregoing example portions of the automated table partitioning method for the PG database, and the specific embodiments thereof can refer to the descriptions of the corresponding examples of the respective portions, which are not repeated herein.
The present invention also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements an automated table partitioning method for a PG database described in any of the above embodiments of the present invention. The remainder of this disclosure may refer to the prior art and will not be described further herein.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The automatic table partitioning method of the PG database, the automatic table partitioning device of the PG database, and the computer readable storage medium provided by the invention are described in detail above. The principles and embodiments of the present invention have been described herein with reference to specific examples, the description of which is intended only to facilitate an understanding of the method of the present invention and its core ideas. It should be noted that it will be apparent to those skilled in the art that various modifications and adaptations of the invention can be made without departing from the principles of the invention and these modifications and adaptations are intended to be within the scope of the invention as defined in the following claims.

Claims (10)

1. An automated table partitioning method for a PG database, comprising:
acquiring a PG database partition instruction;
acquiring the version number of the PG database according to the PG database partition instruction;
downloading and installing the pathman plugin when the version number is lower than V10;
calling the pathman plug-in to perform table partitioning on the PG database;
when the version number is not lower than V10, performing table partitioning on the PG database through a partitioning functional module preset by the PG database;
the step of obtaining the version number of the PG database according to the PG database partition instruction comprises the following steps:
pre-packaging an auto-sh script, and acquiring the PG database version number of the current linux system through psql-version in the auto-sh script;
the downloading and installing the pathman plugin when the version number is lower than V10 comprises:
pre-packaging an extension.sh script, automatically executing the extension.sh script when the version number of the PG database is lower than V10, and realizing the downloading and the installation of the pathman plug-in through the extension.sh script;
when the version number is not lower than V10, performing table partitioning on the PG database by using a partition function module preset in the PG database includes:
and (3) pre-packaging an inspirated.sh script, automatically executing the inspirated.sh script when the version number of the PG database is not lower than V10, and carrying out table partitioning on the PG database through the inspirated.sh script based on a partitioning functional module preset by the PG database.
2. The method of claim 1, further comprising, prior to the fetching of the PG database partition instructions:
acquiring installation completion information of the PG database;
and establishing a main table of the PG database according to the installation completion information.
3. The method of claim 2, wherein the fetching PG database partition instructions comprises:
acquiring a selection instruction corresponding to a target main table in the main table;
and generating a PG database partition instruction corresponding to the target main table according to the selection instruction.
4. The method of claim 3, wherein the invoking the pathman plugin to tablepartition the PG database comprises:
acquiring configuration information of a sub-partition table;
and calling the pathman plug-in and establishing a sub-partition table corresponding to the configuration information.
5. The method of claim 3, wherein when the version number is not lower than V10, table partitioning the PG database by a partition function module preset for the PG database comprises:
when the version number is not lower than V10, acquiring configuration information of a sub-partition table;
and calling a partition function module preset by the PG database, and establishing a sub-partition table corresponding to the configuration information.
6. An automated table partitioning apparatus for a PG database, comprising:
the instruction acquisition module: the method comprises the steps of obtaining a PG database partition instruction;
version number acquisition module: the method comprises the steps of obtaining a version number of a PG database according to a PG database partition instruction;
pathman plug-in module: downloading and installing the pathman plugin when the version number is lower than V10;
low version partition module: the pathman plug-in is used for calling the pathman plug-in to conduct table partitioning on the PG database;
high version partition module: when the version number is not lower than V10, performing table partitioning on the PG database through a partitioning functional module preset by the PG database;
the version number acquisition module is used for:
pre-packaging an auto-sh script, and acquiring the PG database version number of the current linux system through psql-version in the auto-sh script;
the pathman plug-in module is used for:
pre-packaging an extension.sh script, automatically executing the extension.sh script when the version number of the PG database is lower than V10, and realizing the downloading and the installation of the pathman plug-in through the extension.sh script;
the high version partition module is configured to:
and (3) pre-packaging an inspirated.sh script, automatically executing the inspirated.sh script when the version number of the PG database is not lower than V10, and carrying out table partitioning on the PG database through the inspirated.sh script based on a partitioning functional module preset by the PG database.
7. The apparatus as recited in claim 6, further comprising:
PG database module: the method comprises the steps of obtaining installation completion information of a PG database;
and a main table module: and the main table is used for establishing the PG database according to the installation completion information.
8. The apparatus of claim 7, wherein the instruction fetch module comprises:
selecting an instruction unit: the selection instruction is used for acquiring a target main table corresponding to the main table;
an instruction acquisition unit: and the PG database partition instruction is used for generating the PG database partition instruction corresponding to the target main table according to the selection instruction.
9. An automated table partitioning apparatus for a PG database, the apparatus comprising:
a memory: for storing a computer program;
a processor: steps for implementing an automated table partitioning method of a PG database according to any one of claims 1 to 5 when executing said computer program.
10. A computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program when executed by a processor implements the steps of the automated table partitioning method of the PG database of any one of claims 1 to 5.
CN202010879807.2A 2020-08-27 2020-08-27 Automatic table partitioning method and related device for PG database Active CN111897821B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010879807.2A CN111897821B (en) 2020-08-27 2020-08-27 Automatic table partitioning method and related device for PG database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010879807.2A CN111897821B (en) 2020-08-27 2020-08-27 Automatic table partitioning method and related device for PG database

Publications (2)

Publication Number Publication Date
CN111897821A CN111897821A (en) 2020-11-06
CN111897821B true CN111897821B (en) 2023-12-29

Family

ID=73225798

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010879807.2A Active CN111897821B (en) 2020-08-27 2020-08-27 Automatic table partitioning method and related device for PG database

Country Status (1)

Country Link
CN (1) CN111897821B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112597160A (en) * 2020-12-23 2021-04-02 网宿科技股份有限公司 Database table maintenance method and device, server and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105069134A (en) * 2015-08-18 2015-11-18 上海新炬网络信息技术有限公司 Method for automatically collecting Oracle statistical information
CN110489426A (en) * 2019-08-26 2019-11-22 杭州安恒信息技术股份有限公司 A kind of automation partition method, device and the equipment of database table

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090235043A1 (en) * 2008-03-17 2009-09-17 Peeyush Jaiswal Automatic table partitioning roll-in

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105069134A (en) * 2015-08-18 2015-11-18 上海新炬网络信息技术有限公司 Method for automatically collecting Oracle statistical information
CN110489426A (en) * 2019-08-26 2019-11-22 杭州安恒信息技术股份有限公司 A kind of automation partition method, device and the equipment of database table

Also Published As

Publication number Publication date
CN111897821A (en) 2020-11-06

Similar Documents

Publication Publication Date Title
US9348582B2 (en) Systems and methods for software dependency management
CN108595342B (en) Unit testing method and device
CN111638906B (en) SDK (software development kit) access method, device and system
CN108614701B (en) Linux operating system customizing method and device
CN105446712B (en) Application program defect repairing method and device
CN110287170B (en) Database upgrading method, state data calling method, device and storage medium
CN111897821B (en) Automatic table partitioning method and related device for PG database
CN106599167B (en) System and method for supporting increment updating of database
CN112506518A (en) Compiling method and device based on configuration file
CN112559067A (en) Dynamic library loading method and related device
CN112748905B (en) Method and device for initializing and calling basic library, electronic equipment and storage medium
CN106550384A (en) base station batch upgrading method and device
CN116360887A (en) Program parameter loading method, device, equipment and storage medium
CN115794214A (en) Application module metadata management method, device, storage medium and device
CN112527306B (en) Method, device, equipment and medium for realizing independence of modules in project development
CN113535206B (en) Multi-version code upgrading method and system
CN111045947B (en) Test environment construction method and device and related equipment thereof
CN110362320B (en) Command implementation method and device of application development platform
CN111949268A (en) Project compiling method and device, electronic equipment and storage medium
CN112416383A (en) Hot updating method and device for golang program and computer equipment
CN112181450A (en) Method, device, server and storage medium for processing service request
CN116048978B (en) Software service performance self-adaptive test method, system, terminal and medium
CN108241575B (en) Method and device for upgrading test script
CN116431177A (en) Gray scale version updating method, device, equipment and storage medium
CN110955440B (en) Screen locking application separation upgrading method, device, equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant