CN117453732B - CDSS doctor's advice data query optimization method and system - Google Patents

CDSS doctor's advice data query optimization method and system Download PDF

Info

Publication number
CN117453732B
CN117453732B CN202311786746.5A CN202311786746A CN117453732B CN 117453732 B CN117453732 B CN 117453732B CN 202311786746 A CN202311786746 A CN 202311786746A CN 117453732 B CN117453732 B CN 117453732B
Authority
CN
China
Prior art keywords
expression
query
sql query
query statement
rewritten
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
CN202311786746.5A
Other languages
Chinese (zh)
Other versions
CN117453732A (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.)
XIAMEN ZHIYE SOFTWARE ENGINEERING CO LTD
Original Assignee
XIAMEN ZHIYE SOFTWARE ENGINEERING 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 XIAMEN ZHIYE SOFTWARE ENGINEERING CO LTD filed Critical XIAMEN ZHIYE SOFTWARE ENGINEERING CO LTD
Priority to CN202311786746.5A priority Critical patent/CN117453732B/en
Publication of CN117453732A publication Critical patent/CN117453732A/en
Application granted granted Critical
Publication of CN117453732B publication Critical patent/CN117453732B/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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24532Query optimisation of parallel queries
    • 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/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2445Data retrieval commands; View definitions
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24539Query rewriting; Transformation using cached or materialised query results
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/2454Optimisation of common expressions
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24542Plan optimisation
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16HHEALTHCARE INFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR THE HANDLING OR PROCESSING OF MEDICAL OR HEALTHCARE DATA
    • G16H10/00ICT specially adapted for the handling or processing of patient-related medical or healthcare data
    • G16H10/60ICT specially adapted for the handling or processing of patient-related medical or healthcare data for patient-specific data, e.g. for electronic patient records
    • 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)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Operations Research (AREA)
  • Mathematical Physics (AREA)
  • Health & Medical Sciences (AREA)
  • Epidemiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Primary Health Care (AREA)
  • Public Health (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a CDSS doctor's advice data query optimization method and system, which can reduce hundreds of thousands of times of operations originally needed to query a database to several times by rewriting SQL query sentences and caching and filtering query results, reduce interaction times with the database, reduce network overhead, finally reduce query time consumption, improve the execution performance of doctor's advice quality control, improve the concurrency number of interfaces, furthest reduce the blocking time of clinical services, play the positive role of the CDSS doctor's advice quality control function in clinical auxiliary decision, reduce medical errors and improve medical quality.

Description

CDSS doctor's advice data query optimization method and system
Technical Field
The invention relates to the technical field of medical treatment, in particular to a CDSS doctor's advice data query optimization method and system.
Background
The Clinical Decision Support System (CDSS) is used for promoting the construction and development of intelligent hospitals, meeting the information and working requirements of hospitals, having the functions of auxiliary diagnosis, medical advice quality control, treatment scheme recommendation and the like, and having important functions in improving the medical safety, the quality and the like. The CDSS is a computer-aided information system which comprehensively analyzes medical knowledge and patient information by applying information technology, provides various forms of assistance for clinical diagnosis and treatment activities of medical staff and supports clinical decisions.
The doctor's advice quality control function of CDSS needs to comprehensively judge the rationality of patient's examination, inspection, medication doctor's advice according to doctor's advice data such as patient's medical history, diagnosis, examination, inspection, medication. The industry generally adopts a rule engine technology to realize the quality control function of the medical advice, uses SQL sentences to inquire nodes related to the inquiry of patient medical advice data, and caches the SQL inquiry results to optimize the execution performance of the rule engine.
In the prior art, the SQL statement is used for inquiring the medical order data, and the unique hash value of the SQL statement is used as the cached key value to cache the inquiry result, so that the inquiry times of the same medical order inquiry are reduced. However, due to the complexity of the medical profession, the number of quality control rules required to be executed by a single order quality control request may be thousands or tens of thousands, and although the query result is already cached, the number of order query times sent to the database is still up to hundreds of thousands, which still has a great influence on the execution efficiency of the order quality control.
Disclosure of Invention
In order to solve the technical problems mentioned in the background art, the invention provides a CDSS doctor's advice data query optimization method and system, so as to solve the technical problems.
According to one aspect of the present invention, a CDSS order data query optimization method is provided, including:
S1, acquiring an initial SQL query statement, and denoising the initial SQL query statement;
s2, acquiring an actual query parameter value, and carrying out dynamic SQL analysis on the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value;
s3, acquiring list names of medical advice data tables, and rewriting a corresponding conditional expression containing the list names of the medical advice data tables in the filtering conditions of the dynamically generated SQL query sentences to be 1=1 to obtain rewritten SQL query sentences and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression;
s4, acquiring query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and executing the rewritten SQL query sentences to obtain query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value;
And S5, filtering the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
In some specific embodiments, the initial SQL query statement of step S1 comprises a dynamic SQL element written based on the OGNL expression, the dynamic SQL element comprising if, choose, trim, foreach, bind. So as to generate different dynamic SQL sentences according to different query conditions, and enhance the flexibility of the query sentences.
In some specific embodiments, step S1 specifically includes:
s11, deleting spaces contained in comparison operators in the initial SQL query statement;
s12, replacing a plurality of spaces, blank lines, line changing symbols, carriage return symbols and tab symbols in the initial SQL query statement with single space characters;
s13, deleting the spaces between left brackets, the spaces between right brackets, the spaces between commas and the spaces between commas in the initial SQL query statement. Through denoising the initial SQL query statement, the cache hit rate when the SQL query statement is used as a cache key value is prevented from being influenced due to the existence of interference characters, unnecessary dynamic SQL analysis and unnecessary cache can be reduced after denoising, and the effective utilization rate of the internal storage of the program is improved.
In some specific embodiments, step S3 further includes obtaining an order data table name, and determining, based on the order data table name and the order data table column name, whether the dynamically generated SQL query statement requires overwriting.
In some specific embodiments, the step S3 of determining whether the dynamically generated SQL query statement needs to be rewritten based on the order data table name and the order data table column name specifically includes:
s31, judging whether a From expression in the dynamically generated SQL query statement is a data table or not, if so, judging whether the name of the data table is consistent with the name of the doctor' S advice data table, if so, judging whether a white expression in the filtering condition of the dynamically generated SQL query statement is empty or not, and if not, executing the step S32; if the From expression in the filtering condition of the dynamically generated SQL query statement is not a data table, the name of the data table is inconsistent with the name of the doctor's advice data table or the Where expression of the dynamically generated SQL query statement is null, determining that the dynamically generated SQL query statement does not need to be rewritten;
s32, judging the occurrence times of the conditional expressions with the left Bian Jiedian column names of the conditional expressions contained in the white expression being consistent with the column names of the doctor' S advice data table, executing the step S33 if the conditional expressions are only once, and determining that the dynamically generated SQL query statement does not need to be rewritten if the conditional expressions are not or are repeatedly generated;
S33, acquiring query column information of the dynamically generated SQL query statement, judging whether the query column information contains the list name of the medical advice data list, if so, determining that the dynamically generated SQL query statement needs to be rewritten, and if not, determining that the dynamically generated SQL query statement does not need to be rewritten.
In some specific embodiments, in step S3, the rewriting the corresponding conditional expression including the list name of the order data table in the dynamically generated SQL query statement filtering condition to 1=1 specifically includes:
s34, acquiring a Where expression in the filtering condition of the dynamically generated SQL query statement, and taking the Where expression as a parent condition expression;
s35, judging whether the right node of the expression tree of the parent-level conditional expression is a comparison expression or a Like expression, if so, judging whether the left node of the comparison expression or the Like expression is consistent with the list name of the doctor' S advice data list, if so, rewriting the right node of the expression tree of the parent-level conditional expression into 1=1 to obtain a rewritten SQL query statement, and if not, continuing to execute the step S36;
s36, judging whether the right node of the expression tree of the parent-level conditional expression is an In expression, if so, judging whether the column name of the left node of the In expression is consistent with the column name of the doctor' S advice data table, if so, rewriting the right node of the expression tree of the parent-level conditional expression to be 1=1 so as to obtain a rewritten SQL query statement, and if not, continuously executing the step S37;
And S37, judging whether the left node of the expression tree of the parent-level conditional expression is a binary expression, if so, taking the left node of the expression tree of the parent-level conditional expression as a new parent-level conditional expression, and repeatedly executing the steps S35-S37 based on the list name of the doctor' S advice data list. And recursively searching conditional expressions meeting the rewrite conditions in the SQL query statement filter conditions to rewrite the SQL query statement, so as to merge the similar medical advice data query requests and improve the execution performance of medical advice quality control.
In some specific embodiments, the comparison expression of step S3 includes equal to, unequal to, greater than or equal to, less than, and less than or equal to the operators, the Like expression includes a Like operator, and the In expression includes an In operator.
In some specific embodiments, the query result filter In step S3 determines based on the rewritten conditional expression In the rewritten SQL query statement, and obtains a comparison expression filter, like expression filter, and In expression filter corresponding to the rewritten conditional expression.
According to a second aspect of the present invention, a CDSS order data query optimization system is presented, the system comprising:
The denoising module is configured to acquire an initial SQL query statement and denoise the initial SQL query statement;
the analysis module is configured to acquire an actual query parameter value, and dynamically analyze the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value;
the system comprises a rewriting module, a query result filter and a query result filter, wherein the rewriting module is configured to acquire a list name of medical advice data, rewrite a corresponding conditional expression containing the list name of the medical advice data in a dynamically generated SQL query statement filtering condition to be 1=1, and acquire a rewritten SQL query statement and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression;
the execution module is configured to acquire query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and execute the rewritten SQL query sentences to acquire query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value;
And the filtering module is configured to filter the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
According to a third aspect of the present invention, there is provided a computer readable storage medium having stored thereon one or more computer programs which when executed by a computer processor implement the method of any of the above.
The invention provides a CDSS doctor's advice data query optimization method and system, which can reduce hundreds of thousands of times of operations originally needed to query a database to several times by rewriting SQL query sentences and caching and filtering query results, reduce interaction times with the database, reduce network overhead, finally reduce query time consumption, improve the execution performance of doctor's advice quality control, improve the concurrency number of interfaces, furthest reduce the blocking time of clinical services, play the positive role of the CDSS doctor's advice quality control function in clinical auxiliary decision, reduce medical errors and improve medical quality.
Drawings
The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and together with the description serve to explain the principles of the invention. Many of the intended advantages of other embodiments and embodiments will be readily appreciated as they become better understood by reference to the following detailed description. Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 is a flow chart of a CDSS physician order data query optimization method of an embodiment of the present application;
FIG. 2 is an expression tree schematic of a Where expression of one embodiment of the present application;
FIG. 3 is a schematic diagram of a number of queries before optimization of order data according to one embodiment of the present application;
FIG. 4 is a diagram of post-order data optimization query times for one embodiment of the present application;
FIG. 5 is a framework diagram of a CDSS physician order data query optimization system in accordance with an embodiment of the present application;
fig. 6 is a schematic diagram of a computer system suitable for use in implementing embodiments of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that, in the case of no conflict, the embodiments and features in the embodiments may be combined with each other. The present application will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 is a flowchart of a CDSS order data query optimization method according to an embodiment of the present application, as shown in fig. 1, and the method includes:
s1, acquiring an initial SQL query statement, and denoising the initial SQL query statement;
wherein the initial SQL query statement comprises a dynamic SQL element written based on the OGNL expression, the dynamic SQL element comprising if, choose, trim, foreach, bind. So as to generate different dynamic SQL sentences according to different query conditions, and enhance the flexibility of the query sentences.
The step S1 specifically includes:
s11, deleting spaces contained in comparison operators in the initial SQL query statement; the comparison operation symbol comprises less than or equal to (< =), more than or equal to (> =), and not equal to (<or |=);
s12, replacing a plurality of spaces, blank lines, line changing symbols, carriage return symbols and tab symbols in the initial SQL query statement with single space characters;
s13, deleting the spaces between left brackets, the spaces between right brackets, the spaces between commas and the spaces between commas in the initial SQL query statement. Through denoising the initial SQL query statement, the cache hit rate when the SQL query statement is used as a cache key value is prevented from being influenced due to the existence of interference characters, unnecessary dynamic SQL analysis and unnecessary cache can be reduced after denoising, and the effective utilization rate of the internal storage of the program is improved.
S2, acquiring an actual query parameter value, and carrying out dynamic SQL analysis on the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value;
the dynamic SQL analysis includes acquiring an SQL source object (SqlSource object) corresponding to the denoised SQL query statement based on an interface corresponding to Mybatis, and binding an actual query parameter value with the SQL source object to obtain an object (BoundSql object) containing the actual query parameter value, through which the dynamically generated SQL query statement can be acquired, and the object can facilitate the subsequent rewrite operation of the SQL query statement.
In some specific embodiments, step S2 further includes caching the SQL source object (SQL source object) with the denoised SQL query statement as a key value; and when the next query is performed, the SQL source object (SqlSource object) can be directly obtained through the denoised SQL query statement, and the analysis is performed based on the SQL source object (SqlSource object), so that the time consumption of dynamic SQL analysis is reduced.
S3, acquiring list names of medical advice data tables, and rewriting a corresponding conditional expression containing the list names of the medical advice data tables in the filtering conditions of the dynamically generated SQL query sentences to be 1=1 to obtain rewritten SQL query sentences and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression;
It should be noted that, in step S3, the dynamically generated SQL query statement may be parsed by a method of a parameter of ccjsqlpasenti tool class in jsqlparser, and converted into a plainlselect object, and more detailed query information may be obtained by converting into the plainlselect object, so as to perform more precise control and optimization, that is, the From expression and the Where expression fragment in the SQL query statement may be obtained based on the plainlselect object.
Step S3 further includes obtaining an order data table name, and determining whether the dynamically generated SQL query statement needs to be rewritten based on the order data table name and the order data table column name.
The method specifically comprises the following steps:
s31, judging whether a From expression in the dynamically generated SQL query statement is a data table or not, if so, judging whether the name of the data table is consistent with the name of the doctor' S advice data table, if so, judging whether a white expression in the filtering condition of the dynamically generated SQL query statement is empty or not, and if not, executing the step S32; if the From expression in the filtering condition of the dynamically generated SQL query statement is not a data table, the name of the data table is inconsistent with the name of the doctor's advice data table or the Where expression of the dynamically generated SQL query statement is null, determining that the dynamically generated SQL query statement does not need to be rewritten;
S32, judging the occurrence times of the conditional expressions with the left Bian Jiedian column names of the conditional expressions contained in the white expression being consistent with the column names of the doctor' S advice data table, executing the step S33 if the conditional expressions are only once, and determining that the dynamically generated SQL query statement does not need to be rewritten if the conditional expressions are not or are repeatedly generated;
if the number of occurrences of the conditional expression, in which the left Bian Jiedian column name of the conditional expression is consistent with the column name of the order data table, included in the while expression is excessive, that is, the query condition of the SQL query statement is more complex, a deviation between the query result obtained after the subsequent memory filtering and the query result obtained by the initial SQL query statement directly in the database may be caused, so that in order to avoid this problem, it is determined that the dynamically generated SQL query statement does not need to be rewritten.
S33, acquiring query column information of the dynamically generated SQL query statement, judging whether the query column information contains the list name of the medical advice data list, if so, determining that the dynamically generated SQL query statement needs to be rewritten, and if not, determining that the dynamically generated SQL query statement does not need to be rewritten. The SQL query statement to be rewritten can be screened out through the judgment of the steps S31-S33.
Step S3 "rewrite a corresponding conditional expression including the column name of the order data table in the dynamically generated SQL query statement filtering condition to 1=1, to obtain a rewritten SQL query statement and a query result filter" specifically includes:
s34, acquiring a Where expression in the filtering condition of the dynamically generated SQL query statement, and taking the Where expression as a parent condition expression;
s35, judging whether the right node of the expression tree of the parent-level conditional expression is a comparison expression or a Like expression, if so, judging whether the left node of the comparison expression or the Like expression is consistent with the list name of the doctor' S advice data list, if so, rewriting the right node of the expression tree of the parent-level conditional expression into 1=1 to obtain a rewritten SQL query statement, and if not, continuing to execute the step S36;
wherein the comparison expression In step S3 includes equal to, not equal to, greater than, equal to, less than, and less than or equal to the operators, so the comparison expression covers 6 comparison expressions of equal to, not equal to, greater than, equal to, less than, and less than or equal to, and the Like expression includes the Like operator, and the In expression includes the In operator.
S36, judging whether the right node of the expression tree of the parent-level conditional expression is an In expression, if so, judging whether the column name of the left node of the In expression is consistent with the column name of the doctor' S advice data table, if so, rewriting the right node of the expression tree of the parent-level conditional expression to be 1=1 so as to obtain a rewritten SQL query statement, and if not, continuously executing the step S37;
and S37, judging whether the left node of the expression tree of the parent-level conditional expression is a binary expression, if so, taking the left node of the expression tree of the parent-level conditional expression as a new parent-level conditional expression, and repeatedly executing the steps S35-S37 based on the list name of the doctor' S advice data list.
The steps S34-S37 are to recursively search the conditional expressions satisfying the rewrite condition, so as to rewrite the corresponding conditional expressions in the filtering condition of the SQL query statement to 1=1, thereby reducing the repeated execution of the query request of the same kind of order data query requests due to inconsistent order names. The similar doctor's advice inquiry requests, such as a plurality of doctor's advice inquiry requests, are the same except that the doctor's advice names are different, other conditions are the same, this time this inquiry condition of doctor's advice names is replaced with 1=1, and the SQL inquiry statement after the follow-up is rewritten can be executed to inquire out all results that this doctor satisfies other conditions, put into the buffer memory system, filter the required result of each inquiry grammar in the memory.
By way of example, FIG. 2 is an expression tree schematic diagram of a Where expression of an embodiment of the present application, with the Where expression In FIG. 2 as a parent expression, the order data table column name being "order name", first determining whether the right node of the expression tree of the Where expression ("type= 'check'") is a comparison expression first by step S35, it can be seen that the right node is a comparison expression, but the left node of the comparison expression is "type", unlike the order data table column name "order name", then performing step S36 determines whether the right node ("type= 'check'") is an In expression, AND obviously not an In expression, then performing step S37 determines whether the left node ("AND") is a binary expression, it can be seen that, at this time, the left node of the parent expression is a binary expression, so the left node ("AND") is taken as a new parent expression, AND steps S35-S37 are continuously performed until the right node of the new parent expression is ("order name= 'CT'"), the right node is a comparison expression, AND the left node of the comparison expression is "order name", which is the same as the order data table column name, the right node of the current parent expression ("order name= 'CT'") is rewritten to 1=1, the rewriting is ended, AND a comparison expression ("order name= 'CT'") is acquired, which is the rewritten corresponding conditional expression.
In some specific embodiments, the query result filter is configured to perform memory filtering on the query result according to the equivalent result of the rewritten conditional expression, determine based on the rewritten conditional expression In the rewritten SQL query statement, and obtain a comparison expression filter (filter that compares the equalstrofilter with other related expressions), a Like expression filter (Like filter), and an In expression filter (InFilter) corresponding to the rewritten conditional expression. Wherein the comparison expression filter, like filter and In filter can be realized by inheriting the QueryResultFilter base class, and other filters can be further expanded. Taking fig. 2 as an example, after the query condition rewriting step of S35-S37 is performed, the corresponding condition expression ("order name= 'CT'") in the filtering condition of the original query sentence is rewritten to 1=1, and the rewritten corresponding condition expression ("order name= 'CT'") is obtained. The query result filter is obtained based on a determination of the conditional expression that was rewritten, such as the example of FIG. 2 returns an EqualsToFilter filter.
The EqualsToFilter realizes memory filtering operation with the same effect as the expression of ("order name= 'CT'"), namely, circularly judges the rewritten query result list to obtain a record in which the order name is equal to CT.
Further, assuming that the returned filtering condition expression is rewritten ("order name LIKE'%CT%"), a LIKE filter (LikeFilter) is obtained, and the function realized by the corresponding LIKE filter (LikeFilter) is also to circularly judge the rewritten query result list, so as to obtain a record in which the order name contains CT. Other filter implementations are similar to the examples described above.
S4, acquiring query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and executing the rewritten SQL query sentences to obtain query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value;
and S5, filtering the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement. Through rewriting SQL query sentences (step S3) and query result cache filtering (steps S4-S5), hundreds of thousands of operations originally required to query the database can be reduced to a few times, the interaction times with the database are reduced, the network overhead is reduced, the query time consumption is finally reduced, the execution performance of medical advice quality control is improved, the concurrency number of interfaces is improved, the blocking time of clinical services is furthest reduced, the positive effect of the CDSS medical advice quality control function in clinical auxiliary decision is exerted, the medical errors are reduced, and the medical quality is improved.
In order to highlight the technical effects of the application, fig. 3 and fig. 4 are a comparison of the front and rear of the optimization of the medical order data query by using the method of the application, and a cache is used for the same SQL query, and taking a certain medical order quality control request as an example, the number of times of querying related to the medical order is 872 (queryCount).
As shown in fig. 3, 859 order queries (executcount) are executed before query optimization, with 13 cache hits, and the total Time spent on requests exceeds 10 seconds (Time);
referring to FIG. 4, after query optimization, 2 order queries (executContents) are executed, with 870 cache hits, and the total Time taken for the request is about 2.8 seconds (Time);
the comparison of the case optimization before and after can show that repeated similar requests can be greatly reduced through the doctor's advice inquiry optimization, and the execution performance of doctor's advice quality control is improved.
Referring now to fig. 5, fig. 5 is a schematic diagram of optimization of a physician order data query in accordance with one embodiment of the present application, as shown in fig. 5, the system includes a denoising module 501 configured to obtain an initial SQL query statement, and denoise the initial SQL query statement; the analysis module 502 is configured to obtain an actual query parameter value, and dynamically analyze the denoised SQL query statement based on the actual query parameter value to obtain an SQL query statement dynamically generated according to the actual query parameter value; the rewriting module 503 is configured to obtain a list name of the doctor's advice data table, rewrite a corresponding conditional expression containing the list name of the doctor's advice data table in the dynamically generated filtering condition of the SQL query statement to 1=1, and obtain a rewritten SQL query statement and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression; an execution module 504 configured to obtain, based on the actual query parameter value, a query filtering parameter required by a corresponding rewritten SQL query statement, and execute the rewritten SQL query statement to obtain a query result; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value; and the filtering module 505 is configured to filter the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
Referring now to FIG. 6, a schematic diagram of a computer system 600 suitable for use in implementing an electronic device of an embodiment of the present application is shown. The electronic device shown in fig. 6 is only an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present application.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, mouse, etc.; an output portion 607 including a Liquid Crystal Display (LCD) or the like, a speaker or the like; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The drive 610 is also connected to the I/O interface 605 as needed. Removable media 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is installed as needed on drive 610 so that a computer program read therefrom is installed as needed into storage section 608.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network through the communication portion 609, and/or installed from the removable medium 611. The above-described functions defined in the method of the present application are performed when the computer program is executed by a Central Processing Unit (CPU) 601. It should be noted that the computer readable storage medium of the present application may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present application, however, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments described in the present application may be implemented by software, or may be implemented by hardware.
As another aspect, the present application also provides a computer-readable storage medium that may be included in the electronic device described in the above embodiments; or may exist alone without being incorporated into the electronic device. The computer-readable storage medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: acquiring an initial SQL query statement, and denoising the initial SQL query statement; acquiring an actual query parameter value, and carrying out dynamic SQL analysis on the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value; acquiring list names of medical advice data tables, and rewriting a corresponding conditional expression containing the list names of the medical advice data tables in a dynamically generated SQL query statement filtering condition to be 1=1 to obtain a rewritten SQL query statement and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression; acquiring query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and executing the rewritten SQL query sentences to obtain query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value; and filtering the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
The foregoing description is only of the preferred embodiments of the present application and is presented as a description of the principles of the technology being utilized. It will be appreciated by persons skilled in the art that the scope of the invention referred to in this application is not limited to the specific combinations of features described above, but it is intended to cover other embodiments in which any combination of features described above or equivalents thereof is possible without departing from the spirit of the invention. Such as the above-described features and technical features having similar functions (but not limited to) disclosed in the present application are replaced with each other.

Claims (9)

1. A CDSS order data query optimization method, comprising:
s1, acquiring an initial SQL query statement, and denoising the initial SQL query statement;
s2, acquiring an actual query parameter value, and carrying out dynamic SQL analysis on the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value;
s3, acquiring list names of medical advice data tables, and rewriting a corresponding conditional expression containing the list names of the medical advice data tables in the filtering conditions of the dynamically generated SQL query sentences to be 1=1 to obtain rewritten SQL query sentences and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression;
The rewriting the corresponding conditional expression containing the list name of the medical advice data table in the filtering condition of the dynamically generated SQL query statement to 1=1 includes:
s34, acquiring a Where expression in the filtering condition of the dynamically generated SQL query statement, and taking the Where expression as a parent condition expression;
s35, judging whether the right node of the expression tree of the parent-level conditional expression is a comparison expression or a Like expression, if so, judging whether the left node of the comparison expression or the Like expression is consistent with the list name of the doctor' S advice data list, if so, rewriting the right node of the expression tree of the parent-level conditional expression into 1=1 to obtain a rewritten SQL query statement, and if not, continuing to execute the step S36;
s36, judging whether the right node of the expression tree of the parent-level conditional expression is an In expression, if so, judging whether the column name of the left node of the In expression is consistent with the column name of the doctor' S advice data table, if so, rewriting the right node of the expression tree of the parent-level conditional expression to be 1=1 so as to obtain a rewritten SQL query statement, and if not, continuously executing the step S37;
s37, judging whether the left node of the expression tree of the parent-level conditional expression is a binary expression, if so, taking the left node of the expression tree of the parent-level conditional expression as a new parent-level conditional expression, and repeatedly executing the steps S35-S37 based on the list name of the doctor' S advice data list; s4, acquiring query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and executing the rewritten SQL query sentences to obtain query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value;
And S5, filtering the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
2. The CDSS order data query optimization method of claim 1, wherein the initial SQL query statement of step S1 comprises a dynamic SQL element written based on OGNL expressions, the dynamic SQL element comprising if, choose, trim, foreach, bind.
3. The CDSS order data query optimization method of claim 1, wherein step S1 specifically comprises:
s11, deleting spaces contained in comparison operators in the initial SQL query statement;
s12, replacing a plurality of spaces, blank lines, line changing symbols, carriage return symbols and tab symbols in the initial SQL query statement with single space characters;
s13, deleting the spaces between left brackets, the spaces between right brackets, the spaces between commas and the spaces between commas in the initial SQL query statement.
4. The CDSS order data query optimization method of claim 1, wherein step S3 further comprises obtaining an order data table name, and determining whether the dynamically generated SQL query statement requires overwriting based on the order data table name and the order data table column name.
5. The CDSS order data query optimization method according to claim 4, wherein step S3 of determining whether the dynamically generated SQL query statement needs to be rewritten based on the order data table name and the order data table column name specifically comprises:
s31, judging whether a From expression in the dynamically generated SQL query statement is a data table or not, if so, judging whether the name of the data table is consistent with the name of the doctor' S advice data table, if so, judging whether a white expression in the filtering condition of the dynamically generated SQL query statement is empty or not, and if not, executing the step S32; if the From expression in the filtering condition of the dynamically generated SQL query statement is not a data table, the name of the data table is inconsistent with the name of the doctor's advice data table or the Where expression of the dynamically generated SQL query statement is null, determining that the dynamically generated SQL query statement does not need to be rewritten;
s32, judging the occurrence times of the conditional expressions with the left Bian Jiedian column names of the conditional expressions contained in the white expression being consistent with the column names of the doctor' S advice data table, executing the step S33 if the conditional expressions are only once, and determining that the dynamically generated SQL query statement does not need to be rewritten if the conditional expressions are not or are repeatedly generated;
S33, acquiring query column information of the dynamically generated SQL query statement, judging whether the query column information contains the list name of the medical advice data list, if so, determining that the dynamically generated SQL query statement needs to be rewritten, and if not, determining that the dynamically generated SQL query statement does not need to be rewritten.
6. The CDSS order data query optimization method of claim 1, wherein the comparison expression of step S3 includes equal to, unequal to, greater than, equal to, less than, and less than or equal to operators, the Like expression includes Like operators, and the In expression includes In operators.
7. The CDSS order data query optimization method according to claim 1, wherein the query result filter In step S3 is determined based on the rewritten conditional expressions In the rewritten SQL query statement, and a comparison expression filter, like expression filter, and In expression filter corresponding to the rewritten conditional expressions are obtained.
8. A CDSS order data query optimization system, the system comprising:
the denoising module is configured to acquire an initial SQL query statement and denoise the initial SQL query statement;
The analysis module is configured to acquire an actual query parameter value, and dynamically analyze the denoised SQL query statement based on the actual query parameter value to acquire an SQL query statement dynamically generated according to the actual query parameter value;
the system comprises a rewriting module, a query result filter and a query result filter, wherein the rewriting module is configured to acquire a list name of medical advice data, rewrite a corresponding conditional expression containing the list name of the medical advice data in a dynamically generated SQL query statement filtering condition to be 1=1, and acquire a rewritten SQL query statement and a query result filter; the query result filter is used for performing memory filtering on the query result according to the equivalent result of the rewritten conditional expression; the rewriting the corresponding conditional expression containing the list name of the medical advice data table in the filtering condition of the dynamically generated SQL query statement to 1=1 includes: s34, acquiring a Where expression in the filtering condition of the dynamically generated SQL query statement, and taking the Where expression as a parent condition expression; s35, judging whether the right node of the expression tree of the parent-level conditional expression is a comparison expression or a Like expression, if so, judging whether the left node of the comparison expression or the Like expression is consistent with the list name of the doctor' S advice data list, if so, rewriting the right node of the expression tree of the parent-level conditional expression into 1=1 to obtain a rewritten SQL query statement, and if not, continuing to execute the step S36; s36, judging whether the right node of the expression tree of the parent-level conditional expression is an In expression, if so, judging whether the column name of the left node of the In expression is consistent with the column name of the doctor' S advice data table, if so, rewriting the right node of the expression tree of the parent-level conditional expression to be 1=1 so as to obtain a rewritten SQL query statement, and if not, continuously executing the step S37; s37, judging whether the left node of the expression tree of the parent-level conditional expression is a binary expression, if so, taking the left node of the expression tree of the parent-level conditional expression as a new parent-level conditional expression, and repeatedly executing the steps S35-S37 based on the list name of the doctor' S advice data list;
The execution module is configured to acquire query filtering parameters required by corresponding rewritten SQL query sentences based on the actual query parameter values, and execute the rewritten SQL query sentences to acquire query results; when the rewritten SQL query statement is executed, acquiring a query result from a cache based on the rewritten SQL query statement and the query filtering parameter, and if the query result is not acquired, caching the query result based on a spliced character string of the rewritten SQL query statement and the query filtering parameter as a key value;
and the filtering module is configured to filter the query result based on the query result filter to obtain a query result equivalent to the initial SQL query statement.
9. A computer readable storage medium having stored thereon one or more computer programs, which when executed by a computer processor implement the method of any of claims 1 to 7.
CN202311786746.5A 2023-12-25 2023-12-25 CDSS doctor's advice data query optimization method and system Active CN117453732B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311786746.5A CN117453732B (en) 2023-12-25 2023-12-25 CDSS doctor's advice data query optimization method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311786746.5A CN117453732B (en) 2023-12-25 2023-12-25 CDSS doctor's advice data query optimization method and system

Publications (2)

Publication Number Publication Date
CN117453732A CN117453732A (en) 2024-01-26
CN117453732B true CN117453732B (en) 2024-03-01

Family

ID=89593284

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311786746.5A Active CN117453732B (en) 2023-12-25 2023-12-25 CDSS doctor's advice data query optimization method and system

Country Status (1)

Country Link
CN (1) CN117453732B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117854671B (en) * 2024-03-05 2024-05-28 智业软件股份有限公司 Method and system for rapidly calculating execution times of first-day or last-day orders

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038222A (en) * 2017-03-24 2017-08-11 福建天泉教育科技有限公司 Database caches implementation method and its system
CN113434529A (en) * 2021-06-22 2021-09-24 青岛海尔科技有限公司 Business data query method and device, storage medium, processor and electronic equipment
WO2021213160A1 (en) * 2020-11-27 2021-10-28 平安科技(深圳)有限公司 Medical query method and apparatus based on graph neural network, and computer device and storage medium
CN114036178A (en) * 2021-11-05 2022-02-11 深圳创维智慧科技有限公司 Service interface generation method, device, computer and readable storage medium
CA3132004A1 (en) * 2020-09-29 2022-03-29 10353744 Canada Ltd. Sql query optimization method and device
CN116186079A (en) * 2023-04-27 2023-05-30 江苏博云科技股份有限公司 Automatic rewriting and optimizing method for SQL batch queries

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107038222A (en) * 2017-03-24 2017-08-11 福建天泉教育科技有限公司 Database caches implementation method and its system
CA3132004A1 (en) * 2020-09-29 2022-03-29 10353744 Canada Ltd. Sql query optimization method and device
WO2021213160A1 (en) * 2020-11-27 2021-10-28 平安科技(深圳)有限公司 Medical query method and apparatus based on graph neural network, and computer device and storage medium
CN113434529A (en) * 2021-06-22 2021-09-24 青岛海尔科技有限公司 Business data query method and device, storage medium, processor and electronic equipment
CN114036178A (en) * 2021-11-05 2022-02-11 深圳创维智慧科技有限公司 Service interface generation method, device, computer and readable storage medium
CN116186079A (en) * 2023-04-27 2023-05-30 江苏博云科技股份有限公司 Automatic rewriting and optimizing method for SQL batch queries

Also Published As

Publication number Publication date
CN117453732A (en) 2024-01-26

Similar Documents

Publication Publication Date Title
CN117453732B (en) CDSS doctor&#39;s advice data query optimization method and system
US7167848B2 (en) Generating a hierarchical plain-text execution plan from a database query
CN113032362B (en) Data blood edge analysis method, device, electronic equipment and storage medium
US9305044B2 (en) System and method for modelling data
US20090307742A1 (en) Indexing of Security Policies
US20190005117A1 (en) Systems and methods for code parsing and lineage detection
CN111078729B (en) Medical data tracing method, device, system, storage medium and electronic equipment
JP5791149B2 (en) Computer-implemented method, computer program, and data processing system for database query optimization
US11163762B2 (en) Mapping document data to relational data
KR20050059216A (en) Global query correlation attributes
US20100293161A1 (en) Automatically avoiding unconstrained cartesian product joins
CN110990420A (en) Data query method and device
CN110688544A (en) Method, device and storage medium for querying database
CN111782738B (en) Method and device for constructing database table level blood relationship
CN115543402B (en) Software knowledge graph increment updating method based on code submission
CN110889013B (en) Data association method, device, server and storage medium based on XML
US8538976B2 (en) Abstract data model extension through managed physical statement structures
US6374257B1 (en) Method and system for removing ambiguities in a shared database command
US11062048B1 (en) Data structure that facilitates digital rights management
US10261765B1 (en) Enhancing program execution using optimization-driven inlining
US10719424B1 (en) Compositional string analysis
US20170337197A1 (en) Rule management system and method
Balhoff et al. Ubergraph: integrating OBO ontologies into a unified semantic graph
JP2015125572A (en) Method, apparatus, and computer program for specializing serializer
CN113343036B (en) Data blood relationship analysis method and system based on key topological structure analysis

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