CN109828983B - PG database processing method, device, electronic equipment and storage medium - Google Patents

PG database processing method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109828983B
CN109828983B CN201811537728.2A CN201811537728A CN109828983B CN 109828983 B CN109828983 B CN 109828983B CN 201811537728 A CN201811537728 A CN 201811537728A CN 109828983 B CN109828983 B CN 109828983B
Authority
CN
China
Prior art keywords
database
analysis
connection
instruction
execution
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
CN201811537728.2A
Other languages
Chinese (zh)
Other versions
CN109828983A (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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811537728.2A priority Critical patent/CN109828983B/en
Publication of CN109828983A publication Critical patent/CN109828983A/en
Application granted granted Critical
Publication of CN109828983B publication Critical patent/CN109828983B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention provides a PG database processing method, a PG database processing device, electronic equipment and a storage medium. The PG database processing method comprises the following steps: after receiving a PG database analysis instruction, sending a connection request to the PG database; after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database; according to the PG database analysis instruction, basic data is called from the PG database; performing logic operation on the basic data to obtain TOP SQL sentences; and displaying the TOP SQL statement. According to the invention, intelligent searching is realized in an automatic processing mode when the database is operated and maintained, an analysis basis is provided for a developer, and the operation and maintenance efficiency is improved so as to optimize the operation process.

Description

PG database processing method, device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of operation and maintenance technologies, and in particular, to a method and apparatus for processing a PG database, an electronic device, and a storage medium.
Background
A relational database management system, such as MySQL, saves data in different tables rather than putting all the data together, thus improving data processing speed and flexibility. A relational database management system that performs database management using the most commonly used database management language, structured query language (Structured Query Language, abbreviated SQL). Relational database management systems are now widely used in various industries. Database function detection can help users to know the performance of the database and to troubleshoot anomalies.
However, in the prior art, for analysis of the PG database topsql statement, the manufacturer is generally required to provide the AWR report, the form is fixed, the flexibility is lacking, and due to the limitation of the experience level of the technician, the conclusions obtained from the same report are different, so that the conclusions cannot be effectively unified, and inconvenience is caused to the related staff.
Disclosure of Invention
In view of the foregoing, it is necessary to provide a method, an apparatus, an electronic device, and a storage medium for processing a PG database, which implement intelligent search during operation and maintenance of the database in an automated processing manner, and provide an analysis basis for developers, so as to improve operation and maintenance efficiency, so as to optimize an operation process.
A method of PG database processing, the method comprising:
After receiving a PG database analysis instruction, sending a connection request to the PG database;
after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database;
According to the PG database analysis instruction, basic data is called from the PG database;
Performing logic operation on the basic data to obtain TOP SQL sentences;
And displaying the TOP SQL statement.
According to a preferred embodiment of the present invention, the sending a connection request to the PG database includes:
And sending a user name and a password to the PG database for authentication of the PG database.
According to a preferred embodiment of the present invention, the establishing a connection with the PG database comprises:
Acquiring an IP address and a port of the PG database;
Sending the IP address and the port to a configuration connection tool;
And establishing connection with the PG database based on the configuration connection tool.
According to a preferred embodiment of the invention, the base data comprises a combination of one or more of the following:
CPU consumption, execution efficiency, execution time, and execution times.
According to a preferred embodiment of the present invention, the performing a logic operation on the basic data to obtain a TOP SQL statement includes:
sequencing the basic data according to a configuration rule;
and acquiring a statement with a preset bit number before the TOP SQL statement.
According to a preferred embodiment of the present invention, when the TOP SQL statement is exposed, the method further comprises:
when an instruction for displaying an analysis result is received, acquiring a configured statement analysis list;
Matching the TOP SQL sentences with the sentences in the sentence analysis list to obtain matched sentences;
obtaining an analysis result corresponding to the matched sentence from the sentence analysis list;
And displaying the analysis result.
According to a preferred embodiment of the present invention, after the analysis result is displayed, the method further comprises:
When the analysis result shows abnormality, acquiring an execution time period corresponding to the abnormal TOP SQL statement;
Acquiring an execution log in the execution time period;
and displaying the execution log for viewing by a user.
A PG database processing apparatus, the apparatus comprising:
the sending unit is used for sending a connection request to the PG database after receiving the PG database analysis instruction;
The establishing unit is used for establishing connection with the PG database after receiving a connection allowing instruction returned by the PG database;
the calling unit is used for calling basic data from the PG database according to the PG database analysis instruction;
the operation unit is used for carrying out logic operation on the basic data to obtain TOP SQL sentences;
and the display unit is used for displaying the TOP SQL statement.
According to a preferred embodiment of the present invention, the transmitting unit is specifically configured to:
And sending a user name and a password to the PG database for authentication of the PG database.
According to a preferred embodiment of the invention, the establishing unit is specifically configured to:
Acquiring an IP address and a port of the PG database;
Sending the IP address and the port to a configuration connection tool;
And establishing connection with the PG database based on the configuration connection tool.
According to a preferred embodiment of the invention, the base data comprises a combination of one or more of the following:
CPU consumption, execution efficiency, execution time, and execution times.
According to a preferred embodiment of the present invention, the arithmetic unit is specifically configured to:
sequencing the basic data according to a configuration rule;
and acquiring a statement with a preset bit number before the TOP SQL statement.
According to a preferred embodiment of the invention, the device further comprises:
The acquisition unit is used for acquiring a configured statement analysis list when receiving an instruction for displaying an analysis result when displaying the TOP SQL statement;
the matching unit is used for matching the TOP SQL sentences with the sentences in the sentence analysis list to obtain matched sentences;
The acquiring unit is further configured to acquire an analysis result corresponding to the matched sentence from the sentence analysis list;
the display unit is also used for displaying the analysis result.
According to a preferred embodiment of the present invention, the obtaining unit is further configured to obtain, after the analysis result is displayed, an execution time period corresponding to an abnormal TOP SQL statement when the analysis result shows an abnormality;
the acquisition unit is further used for acquiring an execution log in the execution time period;
The display unit is further configured to display the execution log for a user to view.
An electronic device, the electronic device comprising:
A memory storing at least one instruction; and
And the processor executes the instructions stored in the memory to realize the PG database processing method.
A computer-readable storage medium having stored therein at least one instruction for execution by a processor in an electronic device to implement the PG database processing method.
According to the technical scheme, after the PG database analysis instruction is received, the connection request is sent to the PG database, after the connection allowing instruction returned by the PG database is received, connection with the PG database is established again, so that identity authentication is realized, the connection safety is ensured, basic data are purposefully extracted from the PG database according to the PG database analysis instruction, logic operation is carried out on the basic data, TOP SQL sentences are obtained, the TOP SQL sentences are displayed for analysis, an automatic processing mode is adopted, intelligent search is realized during database operation, an analysis basis is provided for developers, operation efficiency is improved, and operation process optimization is carried out.
Drawings
FIG. 1 is a flowchart of a PG database processing method according to a preferred embodiment of the present invention.
FIG. 2 is a functional block diagram of a PG database processing device according to a preferred embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention for implementing the PG database processing method.
Description of the main reference signs
Electronic equipment 1
Memory device 12
Processor and method for controlling the same 13
PG database processing device 11
Transmitting unit 110
Building unit 111
Calling unit 112
Arithmetic unit 113
Display unit 114
Acquisition unit 115
Matching unit 116
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
FIG. 1 is a flowchart of a PG database processing method according to a preferred embodiment of the present invention. The order of the steps in the flowchart may be changed and some steps may be omitted according to various needs.
The PG database processing method is applied to one or more electronic devices, which are devices capable of automatically performing numerical calculation and/or information processing according to preset or stored instructions, and the hardware of the electronic devices includes, but is not limited to, microprocessors, application SPECIFIC INTEGRATED Circuits (ASICs), programmable gate arrays (Field-Programmable GATE ARRAY, FPGA), digital processors (DIGITAL SIGNAL processors, DSPs), embedded devices, and the like.
The electronic device may be any electronic product that can interact with a user in a human-computer manner, such as a personal computer, tablet computer, smart phone, personal digital assistant (PersonalDigital Assistant, PDA), game console, interactive web television (Internet Protocol Television, IPTV), smart wearable device, etc.
The electronic device may also include a network device and/or a user device. Wherein the network device includes, but is not limited to, a single network server, a server group composed of a plurality of network servers, or a Cloud based Cloud Computing (Cloud Computing) composed of a large number of hosts or network servers.
The network in which the electronic device is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), and the like.
And S10, after receiving the PG database analysis instruction, the electronic equipment sends a connection request to the PG database.
In order to solve the inconvenience of manual query or data request from manufacturers in the prior art, the technical scheme provides a scheme for automatically calling TOP SQL sentences from the PG database, brings convenience to users and increases the flexibility of query.
In at least one embodiment of the invention, the PG database (PostgreSQL) is a relational database management system, provides multi-version concurrency control, supports almost all SQL (Structured Query Language ) components (including sub-queries, transaction and user-defined types and functions), and can obtain a very wide range of (development) language bindings (including C, C++, java, perl, tcl, and python).
Specifically, the PG database is provided with a log table, and records all access operations to the database. For each access operation of the user side, the database is correspondingly provided with an execution plan. The execution plan of the database is an execution plan determined by the database server according to query efficiency, time and the like when the database server executes query sentences, and is composed of a plurality of basic operations, such as: traversing the entire table, using indexes, performing nested loops or Hash links, etc. And outputting the query result corresponding to the query statement after executing the execution plan. The log table records each query statement and the corresponding execution plan, and each basic operation of each execution plan is recorded in the log table, so that the basic data of the database can be obtained by reading the log table.
In at least one embodiment of the present invention, the PG database analysis instructions may be triggered by a user (e.g., a PG database analysis button is provided, and a detection process is started by triggering the PG database analysis button, where the PG database analysis button may be a pre-configured virtual button or an entity button, which is not limited by the present invention), or may be automatically executed according to a predetermined frequency.
Specifically, for the frequency of analysis, it may be set as required, for example: at a fixed time of day, or once a half day, etc. To enable timing detection to be performed automatically, it may be performed by a continuous integration tool, such as the Jenkins platform. Jenkins is an open source software project, is a continuous integration tool based on Java development, is used for monitoring continuous repeated work, and aims to provide an open and easy-to-use software platform so that continuous integration of software is possible. And calling an analysis script through the continuous integration tool, so that the detection script automatically and regularly executes the analysis task.
The analysis script may be in any suitable language capable of interfacing with the PG database and reading the underlying data from the PG database, such as: jmeter scripts, shell scripts, python scripts, and the like.
Preferably, the sending, by the electronic device, a connection request to the PG database includes:
and the electronic equipment sends a user name and a password to the PG database for authentication of the PG database.
Further, the PG database verifies the user name and the password, and sends a connection rejection instruction to the electronic equipment when the user name and the password are not verified, or sends a connection permission instruction to the electronic equipment when the user name and the password are verified.
And S11, after receiving a connection allowing instruction returned by the PG database, the electronic equipment establishes connection with the PG database.
In at least one embodiment of the invention, the electronic device may be accessed through ODBC (Open Database Connectivity, open database connection) or JDBC (Java DataBase Connectivity, java database connection) or any other suitable database connection. JDBC is an object-oriented Application Program Interface (API) through which various databases can be accessed. ODBC is a component of the microsoft corporation open services architecture (WOSA, windows Open Services Architecture) that sets up a set of specifications and provides a set of standard APIs (application programming interfaces) for access to databases. The database connection address may be a JDBC connection address or an ODBC connection address. The setting of the analysis script further includes copying a driver connected to a database such as JDBC or ODBC in a script library (e.g., lib library) of the analysis script. So as to establish a connection with the PG database after starting a connection allowing instruction returned by the PG database.
Specifically, the electronic device establishing a connection with the PG database includes:
The electronic equipment acquires the IP address and the port of the PG database, sends the IP address and the port to a configuration connection tool, and establishes connection with the PG database based on the configuration connection tool.
Further, the configuration connection tool includes, but is not limited to, ODBC or JDBC as described above or any other suitable database connection tool, etc.
S12, the electronic equipment invokes basic data from the PG database according to the PG database analysis instruction.
In at least one embodiment of the present invention, the PG database analysis instructions include an analysis range customized by the user, and the electronic device may call the basic data in the analysis range and analyze the basic data.
Specifically, the base data includes, but is not limited to, one or more of the following combinations:
CPU (Central Processing Unit ) consumption, execution efficiency, execution time, execution times, etc.
Further, the electronic device may read the basic data from the log table of the PG database, and may also read the basic data from a TRACE file (sql_trace) or a AWR (Automatic Workload Repository) snapshot file.
Still further, SQL_TRACE files are mainly used to track what is done by background processes and user processes, where execution plans and related statistics can be obtained.
Still further, AWR is essentially a built-in tool to the PG database, which gathers statistics related to performance and derives performance metrics from those statistics to track potential problems.
And S13, the electronic equipment carries out logic operation on the basic data to obtain a TOP SQL sentence.
In at least one embodiment of the invention, the logical operation includes logically ordering the base data.
In at least one embodiment of the present invention, the TOP SQL statement refers to a plurality of statements arranged in front after all SQL statements are ordered according to a certain rule. For example, sorting by execution times, sorting by logic reading, sorting by CUP use time, etc., TOP means taking the first few after sorting.
Specifically, the electronic device performs a logic operation on the basic data, and obtaining a TOP SQL statement includes:
and the electronic equipment sorts the basic data according to a configuration rule, and acquires a statement with a preset number of bits as the TOP SQL statement.
Specifically, the configuration rules may be configured by the electronic device, which may also be different for different underlying data.
Further, the basic data of the SQL statement comprises execution time, execution times, CPU consumption, a corresponding execution plan and the like of the SQL statement. For example: sequencing according to CPU consumption, and obtaining a plurality of SQL sentences with TOP consumption ranks as TOP SQL sentences; the SQL sentences with longer execution time can be determined to be used as the TOP SQL sentences according to the ordering of the execution time of the SQL sentences.
S14, the electronic equipment displays the TOP SQL statement.
In at least one embodiment of the present invention, the electronic device presents the TOP SQL statement in the form of a report, and may display a plurality of function buttons on the presentation interface at the same time, for example: historical data display buttons, data comparison display buttons and the like are used for being selected by the user, so that more services are provided for the user, and the display interface is more friendly.
Preferably, when the TOP SQL statement is exposed, the method further comprises:
When an instruction for displaying an analysis result is received, the electronic equipment acquires a configured statement analysis list, matches the TOP SQL statement with the statement in the statement analysis list to obtain a matched statement, acquires the analysis result corresponding to the matched statement from the statement analysis list, and displays the analysis result.
Specifically, the statement analysis list stores all TOP SQL statements and analysis results corresponding to all TOP SQL statements. The analysis results can be configured by related personnel according to operation and maintenance experience. For example, for TOP SQL statements in which the CPU consumption change rate reaches a preset threshold and the execution reaches a predetermined threshold, a relevant person determines that TOP SQL statements are abnormal, optimization is required, and the conclusion is maintained in the statement analysis list.
The electronic equipment provides a unified analysis result for related personnel, and avoids inconvenience caused to the related personnel due to the limitation of experience level of the technical personnel and the fact that different conclusions are obtained from the same TOP SQL sentence.
Specifically, the analysis result can be displayed in a report form, so that the analysis and the check of the detection personnel are facilitated. The analysis result can be integrated with the TOP SQL statement in a report, so that the analysis result can be conveniently sent to a designated developer, and the developer is assisted to modify and repair codes so as to perfect the execution plan of the SQL query statement. The report may include, but is not limited to, the identification code of the database (e.g., database ID, etc.), the query statement identification code (e.g., query statement ID, etc.), the rules violated, etc. the report may include information necessary to identify the database.
In at least one embodiment of the present invention, the electronic device may display a part of the analysis results in a customized manner, and the rest may be hidden first, and further display of detailed information may be triggered by a development button on the display interface. The developer can directly know the problem through the analysis result, so that the performance and abnormal conditions of the PG database can be quickly known, and the developer is assisted to further analyze and process.
Preferably, after presenting the analysis result, the method further comprises:
When the analysis result shows abnormality, the electronic equipment acquires an execution time period corresponding to the TOP SQL statement of the abnormality, and acquires an execution log in the execution time period, and the electronic equipment displays the execution log for a user to check.
Specifically, the electronic device automatically matches the abnormal execution time period, and displays all execution logs in the abnormal execution time period on the display interface, so that related personnel can perform targeted analysis and processing according to the execution logs.
Of course, in other embodiments, the electronic device may also receive the time period input by the user, and call all execution logs in the time period to meet the query requirement of the user, so that the user can obtain data in a self-defined manner, and the user experience is better.
In summary, the method and the device can send the connection request to the PG database after receiving the PG database analysis instruction; after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database; according to the PG database analysis instruction, basic data is called from the PG database; performing logic operation on the basic data to obtain TOP SQL sentences; and displaying the TOP SQL statement. Therefore, the invention can realize intelligent search in database operation and maintenance through an automatic processing mode, also provides an analysis basis for developers, improves operation and maintenance efficiency, and optimizes the operation process.
Fig. 2 is a functional block diagram of a PG database processing device according to a preferred embodiment of the present invention. The PG database processing device 11 comprises a sending unit 110, a creating unit 111, a retrieving unit 112, an operation unit 113, a display unit 114, an obtaining unit 115, and a matching unit 116. The module/unit referred to in the present invention refers to a series of computer program segments capable of being executed by the processor 13 and of performing a fixed function, which are stored in the memory 12. In the present embodiment, the functions of the respective modules/units will be described in detail in the following embodiments.
Upon receiving the PG database analysis instructions, the transmitting unit 110 transmits a connection request to the PG database.
In order to solve the inconvenience of manual query or data request from manufacturers in the prior art, the technical scheme provides a scheme for automatically calling TOP SQL sentences from the PG database, brings convenience to users and increases the flexibility of query.
In at least one embodiment of the invention, the PG database (PostgreSQL) is a relational database management system, provides multi-version concurrency control, supports almost all SQL (Structured Query Language ) components (including sub-queries, transaction and user-defined types and functions), and can obtain a very wide range of (development) language bindings (including C, C++, java, perl, tcl, and python).
Specifically, the PG database is provided with a log table, and records all access operations to the database. For each access operation of the user side, the database is correspondingly provided with an execution plan. The execution plan of the database is an execution plan determined by the database server according to query efficiency, time and the like when the database server executes query sentences, and is composed of a plurality of basic operations, such as: traversing the entire table, using indexes, performing nested loops or Hash links, etc. And outputting the query result corresponding to the query statement after executing the execution plan. The log table records each query statement and the corresponding execution plan, and each basic operation of each execution plan is recorded in the log table, so that the basic data of the database can be obtained by reading the log table.
In at least one embodiment of the present invention, the PG database analysis instructions may be triggered by a user (e.g., a PG database analysis button is provided, and a detection process is started by triggering the PG database analysis button, where the PG database analysis button may be a pre-configured virtual button or an entity button, which is not limited by the present invention), or may be automatically executed according to a predetermined frequency.
Specifically, for the frequency of analysis, it may be set as required, for example: at a fixed time of day, or once a half day, etc. To enable timing detection to be performed automatically, it may be performed by a continuous integration tool, such as the Jenkins platform. Jenkins is an open source software project, is a continuous integration tool based on Java development, is used for monitoring continuous repeated work, and aims to provide an open and easy-to-use software platform so that continuous integration of software is possible. And calling an analysis script through the continuous integration tool, so that the detection script automatically and regularly executes the analysis task.
The analysis script may be in any suitable language capable of interfacing with the PG database and reading the underlying data from the PG database, such as: jmeter scripts, shell scripts, python scripts, and the like.
Preferably, the transmitting unit 110 transmits a connection request to the PG database includes:
The transmitting unit 110 transmits a user name and a password to the PG database for authentication of the PG database.
Further, the PG database verifies the user name and the password, and sends a connection rejection instruction to the electronic equipment when the user name and the password are not verified, or sends a connection permission instruction to the electronic equipment when the user name and the password are verified.
After receiving the connection permission instruction returned by the PG database, the establishing unit 111 establishes a connection with the PG database.
In at least one embodiment of the present invention, the setup unit 111 may be accessed through ODBC (Open Database Connectivity, open database connection) or JDBC (Java DataBase Connectivity, java database connection) or any other suitable database connection. JDBC is an object-oriented Application Program Interface (API) through which various databases can be accessed. ODBC is a component of the microsoft corporation open services architecture (WOSA, windows Open Services Architecture) that sets up a set of specifications and provides a set of standard APIs (application programming interfaces) for access to databases. The database connection address may be a JDBC connection address or an ODBC connection address. The setting of the analysis script further includes copying a driver connected to a database such as JDBC or ODBC in a script library (e.g., lib library) of the analysis script. So as to establish a connection with the PG database after starting a connection allowing instruction returned by the PG database.
Specifically, the establishing unit 111 establishes a connection with the PG database includes:
The establishing unit 111 obtains the IP address and port of the PG database, sends the IP address and port to a configuration connection tool, and establishes a connection with the PG database based on the configuration connection tool.
Further, the configuration connection tool includes, but is not limited to, ODBC or JDBC as described above or any other suitable database connection tool, etc.
The retrieving unit 112 retrieves the base data from the PG database according to the PG database analysis instructions.
In at least one embodiment of the present invention, the PG database analysis instructions include the user-defined analysis range, and the retrieving unit 112 may retrieve the base data within the analysis range and analyze the base data.
Specifically, the base data includes, but is not limited to, one or more of the following combinations:
CPU (Central Processing Unit ) consumption, execution efficiency, execution time, execution times, etc.
Further, the retrieving unit 112 may read the basic data from the log table of the PG database, and may also read the basic data from a TRACE file (sql_trace) or a AWR (Automatic Workload Repository) snapshot file, which is not limited by the manner of retrieving the basic data.
Still further, SQL_TRACE files are mainly used to track what is done by background processes and user processes, where execution plans and related statistics can be obtained.
Still further, AWR is essentially a built-in tool to the PG database, which gathers statistics related to performance and derives performance metrics from those statistics to track potential problems.
The operation unit 113 performs logic operation on the basic data to obtain a TOP SQL statement.
In at least one embodiment of the invention, the logical operation includes logically ordering the base data.
In at least one embodiment of the present invention, the TOP SQL statement refers to a plurality of statements arranged in front after all SQL statements are ordered according to a certain rule. For example, sorting by execution times, sorting by logic reading, sorting by CUP use time, etc., TOP means taking the first few after sorting.
Specifically, the operation unit 113 performs a logic operation on the basic data, and the obtaining a TOP SQL statement includes:
the operation unit 113 sorts the basic data according to a configuration rule, and obtains a statement with a preset number of digits as the TOP SQL statement.
Specifically, the configuration rule may be configured by the operation unit 113, and the configuration rule is also different for different basic data.
Further, the basic data of the SQL statement comprises execution time, execution times, CPU consumption, a corresponding execution plan and the like of the SQL statement. For example: sequencing according to CPU consumption, and obtaining a plurality of SQL sentences with TOP consumption ranks as TOP SQL sentences; the SQL sentences with longer execution time can be determined to be used as the TOP SQL sentences according to the ordering of the execution time of the SQL sentences.
The presentation unit 114 presents the TOP SQL statement.
In at least one embodiment of the present invention, the presentation unit 114 presents the TOP SQL statement in the form of a report, and may simultaneously display a plurality of function buttons on a presentation interface, for example: historical data display buttons, data comparison display buttons and the like are used for being selected by the user, so that more services are provided for the user, and the display interface is more friendly.
Preferably, when the TOP SQL statement is exposed, the method further comprises:
When receiving an instruction for displaying an analysis result, the acquiring unit 115 acquires a configured statement analysis list, the matching unit 116 matches the TOP SQL statement with the statement in the statement analysis list to obtain a matched statement, the acquiring unit 115 acquires an analysis result corresponding to the matched statement from the statement analysis list, and the displaying unit 114 displays the analysis result.
Specifically, the statement analysis list stores all TOP SQL statements and analysis results corresponding to all TOP SQL statements. The analysis results can be configured by related personnel according to operation and maintenance experience. For example, for TOP SQL statements in which the CPU consumption change rate reaches a preset threshold and the execution reaches a predetermined threshold, a relevant person determines that TOP SQL statements are abnormal, optimization is required, and the conclusion is maintained in the statement analysis list.
The display unit 114 provides a unified analysis result for the related personnel, so as to avoid inconvenience to the related personnel caused by obtaining different conclusions from the same TOP SQL sentence due to the limitation of the experience level of the technical personnel.
Specifically, the analysis result can be displayed in a report form, so that the analysis and the check of the detection personnel are facilitated. The analysis result can be integrated with the TOP SQL statement in a report, so that the analysis result can be conveniently sent to a designated developer, and the developer is assisted to modify and repair codes so as to perfect the execution plan of the SQL query statement. The report may include, but is not limited to, the identification code of the database (e.g., database ID, etc.), the query statement identification code (e.g., query statement ID, etc.), the rules violated, etc. the report may include information necessary to identify the database.
In at least one embodiment of the present invention, the display unit 114 may display a part of the analysis results in a customized manner, the rest may be hidden first, and the step of further displaying detailed information may be triggered by a spread button on the display interface. The developer can directly know the problem through the analysis result, so that the performance and abnormal conditions of the PG database can be quickly known, and the developer is assisted to further analyze and process.
Preferably, after presenting the analysis result, the method further comprises:
when the analysis result shows an abnormality, the obtaining unit 115 obtains an execution time period corresponding to the TOP SQL statement of the abnormality, and obtains an execution log in the execution time period, and the displaying unit 114 displays the execution log for the user to view.
Specifically, the acquiring unit 115 automatically matches the execution time period in which the abnormality occurs, and the displaying unit 114 displays all the execution logs in the execution time period in which the abnormality occurs on the display interface, so that the relevant personnel can perform targeted analysis processing according to the execution logs.
Of course, in other embodiments, the obtaining unit 115 may also receive the time period input by the user, and call all execution logs in the time period to meet the query requirement of the user, so that the user can obtain the data in a self-defined manner, and the user experience is better.
In summary, the method and the device can send the connection request to the PG database after receiving the PG database analysis instruction; after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database; according to the PG database analysis instruction, basic data is called from the PG database; performing logic operation on the basic data to obtain TOP SQL sentences; and displaying the TOP SQL statement. Therefore, the invention can realize intelligent search in database operation and maintenance through an automatic processing mode, also provides an analysis basis for developers, improves operation and maintenance efficiency, and optimizes the operation process.
Fig. 3 is a schematic structural diagram of an electronic device according to a preferred embodiment of the present invention for implementing the PG database processing method.
The electronic device 1 is a device capable of automatically performing numerical calculation and/or information processing according to a preset or stored instruction, and its hardware includes, but is not limited to, a microprocessor, an Application SPECIFIC INTEGRATED Circuit (ASIC), a Programmable gate array (Field-Programmable GATE ARRAY, FPGA), a digital Processor (DIGITAL SIGNAL Processor, DSP), an embedded device, and the like.
The electronic device 1 may also be, but is not limited to, any electronic product that can interact with a user by means of a keyboard, a mouse, a remote control, a touch pad, or a voice control device, such as a personal computer, a tablet, a smart phone, a personal digital assistant (PersonalDigital Assistant, PDA), a game console, an interactive internet protocol television (Internet Protocol Television, IPTV), a smart wearable device, etc.
The electronic device 1 may also be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc.
The network in which the electronic device 1 is located includes, but is not limited to, the internet, a wide area network, a metropolitan area network, a local area network, a virtual private network (Virtual Private Network, VPN), etc.
In one embodiment of the invention, the electronic device 1 includes, but is not limited to, a memory 12, a processor 13, and a computer program, such as a PG database processor, stored in the memory 12 and executable on the processor 13.
It will be appreciated by those skilled in the art that the schematic diagram is merely an example of the electronic device 1 and does not constitute a limitation of the electronic device 1, and may include more or less components than illustrated, or may combine certain components, or different components, e.g. the electronic device 1 may further include input-output devices, network access devices, buses, etc.
The Processor 13 may be a central processing unit (Central Processing Unit, CPU), other general purpose Processor, digital signal Processor (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor may be any conventional processor, etc., and the processor 13 is an operation core and a control center of the electronic device 1, connects various parts of the entire electronic device 1 using various interfaces and lines, and executes an operating system of the electronic device 1 and various installed applications, program codes, etc.
The processor 13 executes the operating system of the electronic device 1 and various types of applications installed. The processor 13 executes the application program to implement the steps in the above-described respective PG database processing method embodiments, such as steps S10, S11, S12, S13, S14 shown in fig. 1.
Or the processor 13, when executing the computer program, performs the functions of the modules/units in the above-described device embodiments, for example: after receiving a PG database analysis instruction, sending a connection request to the PG database; after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database; according to the PG database analysis instruction, basic data is called from the PG database; performing logic operation on the basic data to obtain TOP SQL sentences; and displaying the TOP SQL statement.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory 12 and executed by the processor 13 to complete the present invention. The one or more modules/units may be a series of instruction segments of a computer program capable of performing a specific function for describing the execution of the computer program in the electronic device 1. For example, the computer program may be divided into a transmitting unit 110, a creating unit 111, a retrieving unit 112, an operating unit 113, a presenting unit 114, an acquiring unit 115, and a matching unit 116.
The memory 12 may be used to store the computer program and/or module, and the processor 13 may implement various functions of the electronic device 1 by running or executing the computer program and/or module stored in the memory 12 and invoking data stored in the memory 12. The memory 12 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function, an image playing function, etc.) required for at least one function, and the like; the storage data area may store data (such as audio data, phonebook, etc.) created according to the use of the handset, etc. In addition, memory 12 may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card (SMART MEDIA CARD, SMC), secure Digital (SD) card, flash memory card (FLASH CARD), at least one disk storage device, flash memory device, or other volatile solid-state storage device.
The memory 12 may be an external memory and/or an internal memory of the electronic device 1. Further, the Memory 12 may be a circuit with a Memory function, such as a RAM (Random-Access Memory), a FIFO (FIRST IN FIRST Out), etc., which is not in physical form in the integrated circuit. Alternatively, the memory 12 may be a physical memory, such as a memory bank, a TF card (Trans-FLASH CARD), or the like.
The integrated modules/units of the electronic device 1 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as separate products. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above.
Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
In connection with fig. 1, the memory 12 in the electronic device 1 stores a plurality of instructions to implement a PG database processing method, and the processor 13 can execute the plurality of instructions to implement: after receiving a PG database analysis instruction, sending a connection request to the PG database; after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database; according to the PG database analysis instruction, basic data is called from the PG database; performing logic operation on the basic data to obtain TOP SQL sentences; and displaying the TOP SQL statement.
According to a preferred embodiment of the invention, the processor 13 further executes a plurality of instructions including:
And sending a user name and a password to the PG database for authentication of the PG database.
According to a preferred embodiment of the invention, the processor 13 further executes a plurality of instructions including:
Acquiring an IP address and a port of the PG database;
Sending the IP address and the port to a configuration connection tool;
And establishing connection with the PG database based on the configuration connection tool.
According to a preferred embodiment of the invention, the base data comprises a combination of one or more of the following:
CPU consumption, execution efficiency, execution time, and execution times.
According to a preferred embodiment of the invention, the processor 13 further executes a plurality of instructions including:
sequencing the basic data according to a configuration rule;
and acquiring a statement with a preset bit number before the TOP SQL statement.
According to a preferred embodiment of the invention, the processor 13 further executes a plurality of instructions including:
when an instruction for displaying an analysis result is received, acquiring a configured statement analysis list;
Matching the TOP SQL sentences with the sentences in the sentence analysis list to obtain matched sentences;
obtaining an analysis result corresponding to the matched sentence from the sentence analysis list;
And displaying the analysis result.
According to a preferred embodiment of the invention, the processor 13 further executes a plurality of instructions including:
When the analysis result shows abnormality, acquiring an execution time period corresponding to the abnormal TOP SQL statement;
Acquiring an execution log in the execution time period;
and displaying the execution log for viewing by a user.
Specifically, the specific implementation method of the above instructions by the processor 13 may refer to the description of the relevant steps in the corresponding embodiment of fig. 1, which is not repeated herein.
In the several embodiments provided in the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the modules is merely a logical function division, and there may be other manners of division when actually implemented.
The modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, may be located in one place, or may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional module in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units can be realized in a form of hardware or a form of hardware and a form of software functional modules.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential characteristics thereof.
The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference signs in the claims shall not be construed as limiting the claim concerned.
Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the system claims can also be implemented by means of software or hardware by means of one unit or means. The terms second, etc. are used to denote a name, but not any particular order.
Finally, it should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made to the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention.

Claims (9)

1. A method for processing a PG database, the method comprising:
After receiving a PG database analysis instruction, sending a connection request to the PG database;
after receiving a connection allowing instruction returned by the PG database, establishing connection with the PG database;
Retrieving base data from the PG database according to the PG database analysis instructions, the base data comprising one or more of the following combinations: CPU consumption, execution efficiency, execution time and execution times of the central processing unit;
performing logic operation on the basic data to obtain TOP SQL sentences, wherein the logic operation comprises logic ordering of the basic data;
And displaying the TOP SQL statement.
2. The PG database processing method of claim 1, wherein the sending the connection request to the PG database comprises:
And sending a user name and a password to the PG database for authentication of the PG database.
3. The PG database processing method of claim 1, wherein said establishing a connection with said PG database comprises:
Acquiring an IP address and a port of the PG database;
Sending the IP address and the port to a configuration connection tool;
And establishing connection with the PG database based on the configuration connection tool.
4. The PG database processing method of claim 1, wherein performing a logic operation on the base data to obtain TOP SQL statements comprises:
sequencing the basic data according to a configuration rule;
and acquiring a statement with a preset bit number before the TOP SQL statement.
5. The PG database processing method of claim 1, wherein when the TOP SQL statement is exposed, the method further comprises:
when an instruction for displaying an analysis result is received, acquiring a configured statement analysis list;
Matching the TOP SQL sentences with the sentences in the sentence analysis list to obtain matched sentences;
obtaining an analysis result corresponding to the matched sentence from the sentence analysis list;
And displaying the analysis result.
6. The PG database processing method of claim 5, wherein after displaying the analysis result, the method further comprises:
When the analysis result shows abnormality, acquiring an execution time period corresponding to the abnormal TOP SQL statement;
Acquiring an execution log in the execution time period;
and displaying the execution log for viewing by a user.
7. A PG database processing apparatus, the apparatus comprising:
the sending unit is used for sending a connection request to the PG database after receiving the PG database analysis instruction;
The establishing unit is used for establishing connection with the PG database after receiving a connection allowing instruction returned by the PG database;
A calling unit, configured to call basic data from the PG database according to the PG database analysis instruction, where the basic data includes one or more of the following combinations: CPU consumption, execution efficiency, execution time and execution times of the central processing unit;
The operation unit is used for carrying out logic operation on the basic data to obtain TOP SQL sentences, wherein the logic operation comprises logic ordering on the basic data;
and the display unit is used for displaying the TOP SQL statement.
8. An electronic device, the electronic device comprising:
A memory storing at least one instruction; and
A processor executing instructions stored in the memory to implement the PG database processing method of any one of claims 1 to 6.
9. A computer-readable storage medium, characterized by: the computer-readable storage medium has stored therein at least one instruction that is executed by a processor in an electronic device to implement the PG database processing method of any one of claims 1 to 6.
CN201811537728.2A 2018-12-15 2018-12-15 PG database processing method, device, electronic equipment and storage medium Active CN109828983B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811537728.2A CN109828983B (en) 2018-12-15 2018-12-15 PG database processing method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811537728.2A CN109828983B (en) 2018-12-15 2018-12-15 PG database processing method, device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN109828983A CN109828983A (en) 2019-05-31
CN109828983B true CN109828983B (en) 2024-05-07

Family

ID=66858864

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811537728.2A Active CN109828983B (en) 2018-12-15 2018-12-15 PG database processing method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109828983B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110543405A (en) * 2019-08-15 2019-12-06 平安普惠企业管理有限公司 Log display method and device, storage medium and computer equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1858738A (en) * 2006-02-15 2006-11-08 华为技术有限公司 Method and device for access data bank
CN102385628A (en) * 2011-11-14 2012-03-21 北京锐安科技有限公司 Java data base connectivity (JDBC)-based data distributed processing method
CN103258121A (en) * 2013-04-25 2013-08-21 重庆图珀信息技术有限公司 Clinical blood transfusion evaluating system and evaluating method
CN108733720A (en) * 2017-04-24 2018-11-02 北京京东尚科信息技术有限公司 The on-line testing method and check system of the SQL query of multiple database type

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7496569B2 (en) * 2003-08-29 2009-02-24 Sap Ag Database access statement parser

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1858738A (en) * 2006-02-15 2006-11-08 华为技术有限公司 Method and device for access data bank
CN102385628A (en) * 2011-11-14 2012-03-21 北京锐安科技有限公司 Java data base connectivity (JDBC)-based data distributed processing method
CN103258121A (en) * 2013-04-25 2013-08-21 重庆图珀信息技术有限公司 Clinical blood transfusion evaluating system and evaluating method
CN108733720A (en) * 2017-04-24 2018-11-02 北京京东尚科信息技术有限公司 The on-line testing method and check system of the SQL query of multiple database type

Also Published As

Publication number Publication date
CN109828983A (en) 2019-05-31

Similar Documents

Publication Publication Date Title
CN109558746B (en) Data desensitization method and device, electronic equipment and storage medium
CN109885786B (en) Data caching processing method and device, electronic equipment and readable storage medium
CN110262918B (en) Process crash analysis method and device, distributed equipment and storage medium
CN109376873B (en) Operation and maintenance method, operation and maintenance device, electronic equipment and computer readable storage medium
CN109558384B (en) Log classification method, device, electronic equipment and storage medium
CN109740129B (en) Report generation method, device and equipment based on blockchain and readable storage medium
CN112306700A (en) Abnormal RPC request diagnosis method and device
CN110825731A (en) Data storage method and device, electronic equipment and storage medium
CN112667612A (en) Data quality checking method and device, electronic equipment and storage medium
CN111767270A (en) Data migration method, device, server and storage medium
CN112328275A (en) Data updating method and device for nuclear power plant, terminal equipment and storage medium
CN109634986B (en) System monitoring method, device, computer and computer readable storage medium
CN109828983B (en) PG database processing method, device, electronic equipment and storage medium
CN109828902B (en) Interface parameter determining method and device, electronic equipment and storage medium
CN112199483B (en) Information input assisting method and device, electronic equipment and storage medium
CN111680110B (en) Data processing method, data processing device, BI system and medium
CN112671878A (en) Block chain information subscription method, device, server and storage medium
CN110874365B (en) Information query method and related equipment thereof
CN109885431B (en) Method and apparatus for backing up data
CN110097113B (en) Method, device and system for monitoring working state of display information delivery system
CN109815082B (en) KAFKA theme monitoring method and device, electronic equipment and storage medium
CN111506455A (en) Checking method and device for service release result
CN108197253B (en) Equipment query method, device and equipment of cloud monitoring platform
CA3144122A1 (en) Data verifying method, device and system
CN109840179B (en) RocktMQ thread number monitoring method and device, electronic equipment and storage 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