Method and device for identifying slow queries
By using the data volume prediction value in the temporal database to identify slow queries, and combining the openstsdb storage model to calculate the number of data points and time range, the problem of low slow query identification accuracy in the existing technology is solved, and higher identification accuracy is achieved.
Patent Information
- Application Number
- CN202010081806.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-06
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-02-06
Smart Images

Figure CN113220705B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for identifying slow queries. Background Art
[0002] Slow queries refer to queries that take a long time to query. Figure 1 The current mainstream slow query identification scheme is to define a slow query time threshold, obtain the database query log, and determine whether the execution time of each query is greater than the threshold. If it is greater than the threshold, it is marked as a slow query. When the user executes a query with the same query conditions next time, first determine whether there is a query record with the same query conditions as the current query request and marked as a slow query. If so, the current query is determined to be a slow query.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] For time series databases, the execution time required for a query is closely related to the time range of the query data, the number of tags, etc. If the query time range is long and the execution time is long, it may be marked as a slow query, but if the query time range is short and the execution time is short next time, it will not be marked as a slow query, and the accuracy of slow query identification is very low. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and device for slow query identification, which can improve the accuracy of slow query identification.
[0006] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for identifying a slow query is provided, comprising:
[0007] Receive a user query request, and determine the query conditions and query start and end times of the query request;
[0008] Querying the historical data volume of historical query requests matching the query condition, and determining a predicted value of the data volume of the query request according to the historical data volume and the query start and end time;
[0009] It is identified whether the query request is a slow query according to the data volume prediction value of the query request.
[0010] Optionally, the historical data volume is the number of data points stored in the historical query request per unit time, recorded as unit data points; the data volume prediction value is the prediction value of the number of data points corresponding to the query request;
[0011] Determining a predicted value of the data volume of the query request based on the historical data volume and the query start and end time, including: determining a data time range of the query request based on the query start and end time of the query request; and taking the product of the data time range of the query request and the number of unit data points as a predicted value of the number of data points corresponding to the query request.
[0012] Optionally, before determining the predicted value of the data volume of the query request according to the historical data volume and the query start and end time, the method further includes:
[0013] Determine the data time range of the historical query request according to the query conditions and query start and end times of the historical query request; determine the number of data points corresponding to the historical query request according to the query log of the historical query request; and use the quotient of the number of data points corresponding to the historical query request and the data time range of the historical query request as the unit data point.
[0014] Optionally, the query log is stored using an opentsdb storage model, including at least one row of time series data; each row of the time series data includes: a row key and a row value; the row key includes: an indicator, a timestamp, and a label pair; the row value includes at least one data point, and the data point includes: an indicator value of the indicator corresponding to the time offset from the timestamp;
[0015] Determining the number of data points corresponding to the historical query request according to the query log of the historical query request includes: taking the sum of the numbers of data points included in each row of the time series data corresponding to the historical query request as the number of data points corresponding to the historical query request.
[0016] Optionally, the historical query request or the data time range of the query request is determined according to the following steps:
[0017] Determine the time difference between the query time now of the historical query request or the query request and the query end timestamp; determine whether the time difference is greater than or equal to a preset duration;
[0018] If so, determine the first value of the historical query request or the query end timestamp of the query request rounded to the preset time length, determine the first difference between the historical query request or the query end timestamp of the query request and the first value; determine the second value of the historical query request or the query start timestamp of the query request rounded to the preset time length, determine the second difference between the historical query request or the query start timestamp of the query request and the second value; determine the third difference between the first difference and the second difference; take the sum of the third difference and the preset time length as the time range of the historical query request or the query request;
[0019] Otherwise, determine a fourth difference between the query time of the historical query request or the query request and the first difference; and take the sum of the third difference and the fourth difference as the time range of the historical query request or the query request.
[0020] Optionally, identifying whether the query request is a slow query based on the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
[0021] Optionally, after determining that the query request is a slow query, the method further includes: updating a historical data volume of the historical query request with a predicted data volume value of the query request.
[0022] According to a second aspect of an embodiment of the present invention, a device for identifying a slow query is provided, including:
[0023] A determination module receives a user query request and determines the query conditions and query start and end time of the query request;
[0024] A prediction module, which queries the historical data volume of historical query requests that match the query condition, and determines a data volume prediction value of the query request according to the historical data volume and the query start and end time;
[0025] An identification module identifies whether the query request is a slow query according to a predicted value of the data volume of the query request.
[0026] Optionally, the historical data volume is the number of data points stored in the historical query request per unit time, recorded as unit data points; the data volume prediction value is the prediction value of the number of data points corresponding to the query request;
[0027] The prediction module determines a predicted value of the data volume of the query request based on the historical data volume and the query start and end time, including: determining a data time range of the query request based on the query start and end time of the query request; and taking the product of the data time range of the query request and the number of unit data points as a predicted value of the number of data points corresponding to the query request.
[0028] Optionally, the prediction module is also used to: determine the data time range of the historical query request according to the query conditions and query start and end times of the historical query request before determining the data volume prediction value of the query request according to the historical data volume and the query start and end times; determine the number of data points corresponding to the historical query request according to the query log of the historical query request; and use the quotient of the number of data points corresponding to the historical query request and the data time range of the historical query request as the unit data point.
[0029] Optionally, the query log is stored using an opentsdb storage model, including at least one row of time series data; each row of the time series data includes: a row key and a row value; the row key includes: an indicator, a timestamp, and a label pair; the row value includes at least one data point, and the data point includes: an indicator value of the indicator corresponding to the time offset from the timestamp;
[0030] The prediction module determines the number of data points corresponding to the historical query request based on the query log of the historical query request, including: taking the sum of the numbers of data points included in each row of the time series data corresponding to the historical query request as the number of data points corresponding to the historical query request.
[0031] Optionally, the prediction module is further used to: determine the data time range of the historical query request or the query request according to the following steps:
[0032] Determine the time difference between the query time now of the historical query request or the query request and the query end timestamp; determine whether the time difference is greater than or equal to a preset duration;
[0033] If so, determine the first value of the historical query request or the query end timestamp of the query request rounded to the preset time length, determine the first difference between the historical query request or the query end timestamp of the query request and the first value; determine the second value of the historical query request or the query start timestamp of the query request rounded to the preset time length, determine the second difference between the historical query request or the query start timestamp of the query request and the second value; determine the third difference between the first difference and the second difference; take the sum of the third difference and the preset time length as the time range of the historical query request or the query request;
[0034] Otherwise, determine a fourth difference between the query time of the historical query request or the query request and the first difference; and take the sum of the third difference and the fourth difference as the time range of the historical query request or the query request.
[0035] Optionally, identifying whether the query request is a slow query based on the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
[0036] Optionally, after determining that the query request is a slow query, the method further includes: updating a historical data volume of the historical query request with a predicted data volume value of the query request.
[0037] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for slow query identification, including:
[0038] one or more processors;
[0039] a storage device for storing one or more programs,
[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0041] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0042] An embodiment of the above invention has the following advantages or beneficial effects: by determining the data volume prediction value of the current query request based on the query start and end time of the current query request and the historical data volume of historical query requests, and then identifying whether the current query request is a slow query based on the data volume prediction value, the accuracy of slow query identification can be improved.
[0043] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0045] Figure 1 is a schematic diagram of a slow query identification method in the prior art;
[0046] Figure 2 is a schematic diagram of the main process of the method for slow query identification according to an embodiment of the present invention;
[0047] Figure 3 is a flow chart of a method for slow query identification in an optional embodiment of the present invention;
[0048] Figure 4 is a schematic diagram of the data time range in some embodiments of the present invention;
[0049] Figure 5 is a schematic diagram of the data time range in other embodiments of the present invention;
[0050] Figure 6 is a schematic diagram of main modules of a device for slow query identification according to an embodiment of the present invention;
[0051] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0052] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0054] According to one aspect of an embodiment of the present invention, a method for identifying slow queries is provided.
[0055] Figure 2 FIG. 1 is a schematic diagram of the main process of the method for identifying slow queries according to an embodiment of the present invention. Figure 2 As shown, the method for identifying slow queries includes: step S201, step S202 and step S203.
[0056] Step S201: Receive a user query request, and determine the query conditions and query start and end times of the query request.
[0057] The query condition is used to indicate the data object that the user needs to query. The query condition can include a field to indicate the unique identifier of the data object, and the data object to be queried is determined based on the identifier. The query condition can also include multiple fields, and the data object to be queried is uniquely determined through multiple fields.
[0058] Optionally, each data object that needs to be queried is stored using the opentsdb (distributed, scalable time series database based on hbase) storage model. The query conditions include: the metric to be queried, the tag to be queried (tagk), and the value corresponding to the tag (tagv). The tag describes the key-value pair of the monitoring indicator, for example, cluster=lf, module=searcher, which means that the computer room is lf and the module is searcher. An indicator can be set with multiple tags, and users can filter and view time series data according to different tags. For example, the indicator is the CPU usage rate (cpu.usage), the tag is the location of the computer room, and the value corresponding to the tag is region A.
[0059] The query start and end time is used to indicate the query start timestamp and query end timestamp of the user's query. For example, when you need to query data from August 20, 2019 to August 21, 2019, the query start timestamp is August 20, 2019, and the query end timestamp is August 21, 2019.
[0060] Step S202: query the historical data volume of the historical query requests that match the query condition, and determine the data volume prediction value of the query request according to the historical data volume and the query start and end time.
[0061] The historical data volume is used to indicate the size of the data in the query log obtained by the historical query request. The historical data volume can be measured by the size of the storage space occupied by the data contained in the query log or by the number of data contained in the query log.
[0062] Optionally, the historical data volume is the number of data points stored in the historical query request per unit time, recorded as the unit data point number; the data volume prediction value is the prediction value of the number of data points corresponding to the query request. Determining the data volume prediction value of the query request based on the historical data volume and the query start and end time includes: determining the data time range of the query request based on the query start and end time of the query request; and taking the product of the data time range of the query request and the unit data point number as the prediction value of the number of data points corresponding to the query request.
[0063] This embodiment determines the number of data points of the current query request based on the number of unit data points corresponding to the historical query requests of the current query condition system, and then identifies whether the current query request is a slow query, so that even if the query start and end time of the current query request is different from the query start timestamp of the historical query, it is possible to accurately identify whether the current query request is a slow query, thereby avoiding the problem of poor accuracy caused by using the query execution time to identify the slow query.
[0064] In addition, the query start timestamp is not necessarily the same as the start time of the queried data, and the query end timestamp is not necessarily the same as the end time of the queried data. Compared with calculating the number of data points of the current query based on the time difference between the query start timestamp and the query end timestamp, the present invention determines the data time range of the query request based on the query start timestamp and the query end timestamp, and calculates the number of data points of the current query based on the data time range, which can further improve the recognition accuracy of slow queries.
[0065] Optionally, before determining the data volume prediction value of the query request according to the historical data volume and the query start and end time, it also includes: determining the data time range of the historical query request according to the query conditions and query start and end time of the historical query request; determining the number of data points corresponding to the historical query request according to the query log of the historical query request; and taking the quotient of the number of data points corresponding to the historical query request and the data time range of the historical query request as the unit data point. The method of calculating the positioning data points in this way is simple.
[0066] Optionally, the query log is stored using the opentsdb storage model, including at least one row of time series data; each row of the time series data includes: a row key and a row value; the row key includes: an indicator, a timestamp, and a tag pair; the row value includes at least one data point, and the data point includes: an indicator value of the indicator corresponding to the time offset corresponding to the time offset from the timestamp. Determine the number of data points corresponding to the historical query request based on the query log of the historical query request, including: taking the sum of the number of data points included in each row of the time series data corresponding to the historical query request as the number of data points corresponding to the historical query request.
[0067] The definition of timestamp can be selectively set according to actual conditions. Timestamp can be at the hour level, that is, a row of time series data stores all data points of a query condition within an hour. For example, the timestamps of multiple time series data are 1 o'clock, 2 o'clock, 3 o'clock, ..., 24 o'clock, etc. The timestamp can also be other time levels. For example, the timestamps of multiple time series data are 3 o'clock, 6 o'clock, 9 o'clock, ..., 24 o'clock, etc., that is, a row of time series data stores all data points of a query condition within two hours. The minimum time unit of the timestamp can also be selectively set according to actual conditions, such as supporting millisecond or second time settings. For example, the specific value of the timestamp is a certain year, month, day, hour, minute, and second.
[0068] Each row of the data table in the opentsdb storage model represents a time series data. For example, Table 1 shows the query log corresponding to the historical query request A, which includes three rows of time series data.
[0069] Table 1 Time series data in query logs
[0070]
[0071]
[0072] Each row of time series data in Table 1 has two columns. The first column is the row key, which consists of a metric, a timestamp, and a tag pair (tagk1=tagv1, tagk2=tagv2, ..., tagkn=tagvn). The timestamp is an hourly timestamp at the hour, and supports seconds. The second column is a collection of data points. Each data point contains two parts: one is the time offset from the timestamp, which ranges from 0 to 3599 seconds, and the other is the metric value corresponding to the time offset. A row of time series data stores all the data points of a query condition within an hour. The sum of the number of data points included in each row of time series data in Table 1 is the number of data points corresponding to the historical query request A.
[0073] Optionally, the historical query request or the data time range of the query request is determined according to the following steps:
[0074] Determine the time difference between the query time now of the historical query request or the query request and the query end timestamp; determine whether the time difference is greater than or equal to a preset duration;
[0075] If so, determine the first value of the historical query request or the query end timestamp of the query request rounded to the preset time length, determine the first difference between the historical query request or the query end timestamp of the query request and the first value; determine the second value of the historical query request or the query start timestamp of the query request rounded to the preset time length, determine the second difference between the historical query request or the query start timestamp of the query request and the second value; determine the third difference between the first difference and the second difference; take the sum of the third difference and the preset time length as the time range of the historical query request or the query request;
[0076] Otherwise, determine a fourth difference between the query time of the historical query request or the query request and the first difference; and take the sum of the third difference and the fourth difference as the time range of the historical query request or the query request.
[0077] See also Figure 4 , when the time difference is greater than or equal to the preset duration, the time range of the historical query request or the query request is:
[0078] scan_time=(end-end%T)-(start-start%T)+T;
[0079] See also Figure 5 , when the time difference is less than the preset duration, the time range of the historical query request or the query request is:
[0080] scan_time=(end-end%T)-(start-start%T)+[now-(end-end%T)];
[0081] In the formula, start represents the query start timestamp of the historical query request or the query request, end represents the query end timestamp of the historical query request or the query request, now represents the query time of the historical query request or the query request, and T represents the preset duration. The preset duration is the time difference between two adjacent query start timestamps or query start and end timestamps.
[0082] exist Figure 4 and Figure 5 In the illustrated embodiment, the timestamp is at the hour level, and the preset duration is one hour. Figure 4 and Figure 5 , _end = end-end%T, _start = start-start%T, T is 3600 seconds.
[0083] Step S203: Identify whether the query request is a slow query based on the data volume prediction value of the query request. A slow query refers to a query request with a long query time. For a slow query, the database system resources used by the slow query at the back end can be limited to avoid affecting other users.
[0084] Optionally, identifying whether the query request is a slow query based on the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
[0085] Optionally, after determining that the query request is a slow query, the method further includes: updating the historical data volume of the historical query request with the data volume prediction value of the query request. By continuously updating the historical data volume, the timeliness of the historical data volume can be guaranteed, and the accuracy of slow query identification based on the historical data volume can be improved.
[0086] Figure 3 It is a schematic diagram of the main process of the method for slow query identification according to an embodiment of the present invention.
[0087] like Figure 3 As shown, the method for identifying slow queries includes the following steps:
[0088] Step S301: Receive a user query request and determine the query conditions and query start and end time of the query request.
[0089] Step S302: determine whether there is a historical query request that matches the query condition of the current query request; if so, jump to step S307; otherwise, jump to step S303;
[0090] Step S303: execute the current query request and obtain the query log of the current query request;
[0091] Step S304, determining the total number of data points of the current query request according to the query log;
[0092] Step S305, determining the number of data points stored in a unit time according to the query start and end time of the current query request and the total number of data points;
[0093] Step S306, add the number of unit data points corresponding to the query conditions of the current query request. Exemplarily, the query conditions of the current query request and the corresponding number of positioning data points are recorded in MySQL (a relational database management system). When the same query conditions are queried next time, the data time range can be calculated according to the start and end time of the query, and the estimated number of data points for the next query can be calculated by multiplying it by the recorded number of unit data points. If it is greater than the preset threshold, the next query can be determined to be a slow query, and the query resources used in the backend can be limited. At the same time, the new number of positioning data points is calculated through the data time range and query log of the next query to update the number of unit data points recorded in MySQL;
[0094] Step S307: determining a predicted value of the data volume of the current query request according to the query start and end time of the current query request and the number of unit data points of the historical query requests;
[0095] Step S308, determine whether the data volume prediction value of the current query request is greater than or equal to a preset threshold; if so, jump to step S309; otherwise, jump to step S310;
[0096] Step S309: determine that the current query request is a slow query;
[0097] Step S310: Determine whether the current query request is a slow query.
[0098] For the same query condition, this embodiment calculates the number of data points stored per unit time for the query condition based on the number of data points included in the query log corresponding to the historical query request and the start and end time of the query request when the user queries for the first time. When the user queries the same query condition for the second time, the number of data points for this query is estimated based on the start and end time of the query request and the number of data points per unit time of the previous query. When the number of data points is greater than a preset threshold, the query is determined to be a slow query. At the same time, the number of data points per unit time corresponding to the query condition is recalculated for this query and continuously updated. This embodiment can greatly improve the accuracy of slow query identification.
[0099] In large-scale distributed application systems, in order to understand the operating status of the system in real time (whether the function is good, whether the performance is good, etc.), a monitoring system is often built. Since the monitoring data is mostly time-series data, the scale is large, and aggregate calculation is required, the opentsdb database is usually selected. The embodiment of the present invention is suitable for slow query identification when querying the opentsdb database.
[0100] According to a second aspect of an embodiment of the present invention, a device for implementing the above method is provided.
[0101] Figure 6 It is a schematic diagram of main modules of the slow query identification device according to an embodiment of the present invention.
[0102] like Figure 6 As shown, the slow query identification device 600 includes:
[0103] Determination module 601, receiving a user query request, and determining a query condition and a query start and end time of the query request;
[0104] Prediction module 602, querying the historical data volume of the historical query request matching the query condition, and determining the data volume prediction value of the query request according to the historical data volume and the query start and end time;
[0105] The identification module 603 identifies whether the query request is a slow query according to the data volume prediction value of the query request.
[0106] Optionally, the historical data volume is the number of data points stored in the historical query request per unit time, recorded as unit data points; the data volume prediction value is the prediction value of the number of data points corresponding to the query request;
[0107] The prediction module determines a predicted value of the data volume of the query request based on the historical data volume and the query start and end time, including: determining a data time range of the query request based on the query start and end time of the query request; and taking the product of the data time range of the query request and the number of unit data points as a predicted value of the number of data points corresponding to the query request.
[0108] Optionally, the prediction module is also used to: determine the data time range of the historical query request according to the query conditions and query start and end times of the historical query request before determining the data volume prediction value of the query request according to the historical data volume and the query start and end times; determine the number of data points corresponding to the historical query request according to the query log of the historical query request; and use the quotient of the number of data points corresponding to the historical query request and the data time range of the historical query request as the unit data point.
[0109] Optionally, the query log is stored using an opentsdb storage model, including at least one row of time series data; each row of the time series data includes: a row key and a row value; the row key includes: an indicator, a timestamp, and a label pair; the row value includes at least one data point, and the data point includes: an indicator value of the indicator corresponding to the time offset from the timestamp;
[0110] The prediction module determines the number of data points corresponding to the historical query request based on the query log of the historical query request, including: taking the sum of the numbers of data points included in each row of the time series data corresponding to the historical query request as the number of data points corresponding to the historical query request.
[0111] Optionally, the prediction module is further used to: determine the data time range of the historical query request or the query request according to the following steps:
[0112] Determine the time difference between the query time now of the historical query request or the query request and the query end timestamp; determine whether the time difference is greater than or equal to a preset duration;
[0113] If so, determine the first value of the historical query request or the query end timestamp of the query request rounded to the preset time length, determine the first difference between the historical query request or the query end timestamp of the query request and the first value; determine the second value of the historical query request or the query start timestamp of the query request rounded to the preset time length, determine the second difference between the historical query request or the query start timestamp of the query request and the second value; determine the third difference between the first difference and the second difference; take the sum of the third difference and the preset time length as the time range of the historical query request or the query request;
[0114] Otherwise, determine a fourth difference between the query time of the historical query request or the query request and the first difference; and take the sum of the third difference and the fourth difference as the time range of the historical query request or the query request.
[0115] Optionally, identifying whether the query request is a slow query based on the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
[0116] Optionally, after determining that the query request is a slow query, the method further includes: updating a historical data volume of the historical query request with a predicted data volume value of the query request.
[0117] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for slow query identification, including:
[0118] one or more processors;
[0119] a storage device for storing one or more programs,
[0120] When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0121] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0122] Figure 7 An exemplary system architecture 700 is shown to which the method or apparatus for slow query identification according to the embodiments of the present invention may be applied.
[0123] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0124] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0125] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0126] The server 705 may be a server that provides various services, such as a backend management server (only for example) that supports shopping websites browsed by users using the terminal devices 701, 702, and 703. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only for example) to the terminal device.
[0127] It should be noted that the method for identifying slow queries provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the device for identifying slow queries is generally disposed in the server 705 .
[0128] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0129] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0130] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0131] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0132] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0133] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0134] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor, for example, may be described as: a processor comprising: a determination module, receiving a user query request, determining the query conditions and query start and end time of the query request; a prediction module, querying the historical data volume of historical query requests matching the query conditions, and determining the data volume prediction value of the query request based on the historical data volume and the query start and end time; an identification module, identifying whether the query request is a slow query based on the data volume prediction value of the query request. Among them, the names of these modules do not constitute a limitation on the module itself in some cases. For example, the determination module may also be described as "a module that identifies whether the query request is a slow query based on the data volume prediction value of the query request."
[0136] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a user query request, determining the query conditions and query start and end time of the query request; querying the historical data volume of the historical query request matching the query condition, and determining the data volume prediction value of the query request based on the historical data volume and the query start and end time; identifying whether the query request is a slow query based on the data volume prediction value of the query request.
[0137] According to the technical solution of an embodiment of the present invention, by determining the data volume prediction value of the current query request based on the query start and end time of the current query request and the historical data volume of historical query requests, and then identifying whether the current query request is a slow query based on the data volume prediction value, the accuracy of slow query identification can be improved.
[0138] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for identifying slow queries, It is characterized in that include: Receive a user query request, and determine the query conditions and query start and end times of the query request; Querying the historical data volume of historical query requests matching the query condition, and determining the data volume prediction value of the query request according to the historical data volume and the query start and end time, including: determining the data time range of the query request according to the query start and end time of the query request; taking the product of the data time range of the query request and the unit data point number as the prediction value of the data point number corresponding to the query request; wherein the historical data volume is the number of data points stored in the historical query request per unit time, recorded as the unit data point number; the data volume prediction value is the prediction value of the data point number corresponding to the query request; Identifying whether the query request is a slow query according to the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
2. The method according to claim 1, It is characterized in that Before determining the data volume prediction value of the query request according to the historical data volume and the query start and end time, the method further includes: Determine the data time range of the historical query request according to the query conditions and query start and end times of the historical query request; determine the number of data points corresponding to the historical query request according to the query log of the historical query request; and use the quotient of the number of data points corresponding to the historical query request and the data time range of the historical query request as the unit data point.
3. The method according to claim 2, It is characterized in that The query log is stored using the opentsdb storage model and includes at least one row of time series data; Each row of the time series data includes: a row key and a row value; the row key includes: an indicator, a timestamp, and a tag pair; the row value includes at least one data point, and the data point includes: an indicator value of the indicator corresponding to the time offset from the timestamp; Determining the number of data points corresponding to the historical query request according to the query log of the historical query request includes: taking the sum of the numbers of data points included in each row of the time series data corresponding to the historical query request as the number of data points corresponding to the historical query request.
4. The method according to claim 1 or 2, It is characterized in that The historical query request or the data time range of the query request is determined according to the following steps: Determine the time difference between the query time now of the historical query request or the query request and the query end timestamp; determine whether the time difference is greater than or equal to a preset duration; If so, determining a first value of the historical query request or the query end timestamp of the query request rounded to a preset time length, and determining a first difference between the historical query request or the query end timestamp of the query request and the first value; Determine a second value of the historical query request or the query start timestamp of the query request rounded to a preset time length, and determine a second difference between the historical query request or the query start timestamp of the query request and the second value; determining a third difference between the first difference and the second difference; Using the sum of the third difference and the preset duration as the time range of the historical query request or the query request; otherwise, determining a fourth difference between the query time of the historical query request or the query request and the first difference; The sum of the third difference and the fourth difference is used as the time range of the historical query request or the query request.
5. The method according to claim 1, It is characterized in that After determining that the query request is a slow query, the method further includes: updating the historical data volume of the historical query request with the predicted value of the data volume of the query request.
6. A device for identifying slow queries, It is characterized in that include: A determination module receives a user query request and determines the query conditions and query start and end time of the query request; A prediction module, querying the historical data volume of the historical query request matching the query condition, and determining the data volume prediction value of the query request according to the historical data volume and the query start and end time; An identification module, which identifies whether the query request is a slow query according to a predicted value of the data volume of the query request; The historical data volume is the number of data points stored in the historical query request per unit time, recorded as the unit data point number; the data volume prediction value is the prediction value of the data point number corresponding to the query request; determining the data volume prediction value of the query request according to the historical data volume and the query start and end time includes: determining the data time range of the query request according to the query start and end time of the query request; taking the product of the data time range of the query request and the unit data point number as the prediction value of the data point number corresponding to the query request; Identifying whether the query request is a slow query according to the data volume prediction value of the query request includes: determining whether the data volume prediction value of the query request is greater than a preset threshold; if so, determining that the query request is a slow query; otherwise, determining that the query request is not a slow query.
7. An electronic device for slow query identification, It is characterized in that include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Slow inquiry information retrieval method, device, server and readable storage medium
CN108520052A
Predictive data caching
US20110055202A1
