Data paging query method and device, electronic equipment and storage medium
Through the window sliding technology of small-period query time range and data index identification, the depth paging problem of data in uneven distribution by time dimension is solved, query efficiency and performance stability are improved, and resource waste is avoided.
Patent Information
- Application Number
- CN202411314296.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-10-29
AI Technical Summary
When existing paging query technology processes large amounts of data, especially when the data is unevenly distributed in time dimensions, the query efficiency is low and the depth paging problem is serious, resulting in waste of resources and unstable query performance.
Use small-period query time range and data index identifier to slide the window, dynamically adjust the query interval, optimize data query through methods such as back-turning, forward-turning, back-turning, forward-turning, and forward-turning, etc. to ensure that the query time per page is not Affected by depth, keep query performance stable.
It effectively reduces the total amount of data in a single query, improves query efficiency, avoids resource waste and query performance reduction caused by deep paging, and ensures stable query performance in large data scenarios.
Smart Images

Figure CN119202328A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of paging query, and in particular to a data paging query method, device, electronic device, and storage medium. Background Art
[0002] The advent of the digital age has prompted the storage of massive amounts of data in databases for subsequent query and analysis, and paging query technology is mainly used to address the limitations of visual interfaces and meet data query efficiency requirements.
[0003] Specifically, data paging query refers to the process of calculating the data content displayed on each page and the number of query pages according to the number of display items specified by the user under the premise of querying a large amount of data. For example, if a customer needs to query n data items from the database and requires that m items be displayed per page, the customer can browse a total of [n / m] pages of data, and the last page will only display n%m items of data. However, as the amount of data queried by customers increases, the efficiency of querying data per page decreases, and the problem of deep paging becomes significant. Summary of the invention
[0004] The embodiments of the present application provide a data paging query method, device, electronic device, and storage medium to implement window sliding of data according to a sequence or time dimension to implement data paging query.
[0005] The present application embodiment adopts the following technical solutions:
[0006] In a first aspect, an embodiment of the present application provides a data paging query method, wherein the method comprises:
[0007] In response to a page query request, when flipping back in order and querying the home page data, query the time range of the target data source in the small cycle query;
[0008] Calculate the total number of queries based on the time range of the target data source in the small cycle query;
[0009] When the total number of queries exceeds a preset threshold, the time range of the small-cycle query of the target data source is narrowed to obtain an adjusted time range of the small-cycle query of the target data source;
[0010] Based on the adjusted time range of the target data source in the small cycle query, start querying from the small cycle data index identifier and return the query result;
[0011] Alternatively, when flipping forward in positive order and querying the first page data, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used to start the query and return the query results.
[0012] In some embodiments, the method further includes: when flipping back in positive order and querying non-homepage data, using the small cycle query start time and the small cycle data index identifier recorded on the previous page;
[0013] Determine the small cycle time span according to the small cycle query start time recorded on the previous page, and display the data on the page according to the small cycle data index identifier;
[0014] If the number of data items displayed on the page according to the data identified by the small-cycle data index does not meet the preset query number, the small cycle is moved to perform data query.
[0015] In some embodiments, the query based on the adjusted time range of the target data source in the small cycle, starting from the small cycle data index identifier, and returning the query result includes:
[0016] When starting to query from the small cycle data index identifier, determine whether the current small cycle has queried the preset number of query items;
[0017] If yes, update the small-cycle data index identifier to the small-cycle data index identifier + the preset number of queries, update the global data index identifier to the global data index identifier + the preset number of queries, and keep the small-cycle query start time unchanged;
[0018] When starting the query from the small cycle data index identifier, it is determined whether n1 pieces of data are queried in the current small cycle and n1 is less than the preset number of query pieces, and the time range of the mobile small cycle query is the first time;
[0019] When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1 data;
[0020] If satisfied, update the small cycle data index identifier to the small cycle data index identifier + the preset query number - n1, update the global data index identifier to the global data index identifier + the preset query number, and update the small cycle query start time to the second time;
[0021] If it is not satisfied, all data of the current small cycle will be queried and the time range of the small cycle query will continue to move;
[0022] When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1-n2 data;
[0023] If satisfied, the small cycle data index identifier is updated to the small cycle data index identifier + the preset query number - n1-n2, the global data index identifier is updated to the global data index identifier + the preset query number, and the small cycle query start time is updated to the third time;
[0024] If not, continue to move the small cycle until the number of queries this time meets the preset number of queries or the end time of the small cycle is greater than the end time of the global query.
[0025] In some embodiments, when the first page data is queried in forward order, the query is started using the small cycle query start time and the small cycle data index identifier recorded on the previous page, and the query results are returned, including:
[0026] When starting a query using the small cycle data index identifier recorded on the previous page, determine whether each small cycle data index identifier - 1 satisfies the preset query number + the previous page request number;
[0027] If satisfied, the data of the current small cycle data index is queried for page display, the small cycle data index identifier is updated to the small cycle data index identifier-the number of requests on the previous page, and the global data index identifier is updated to the global data index identifier-the number of requests on the previous page, and the small cycle query start time remains unchanged;
[0028] If not, all the remaining numbers of the current small cycle are checked, the small cycle is moved forward, and the total number of small cycle data after the movement is calculated to determine whether the preset query number + the number of requests on the previous page - the number of remaining numbers of the current small cycle is met;
[0029] If it is satisfied, the query will be queried for the data of the current small cycle index being the total number of the current small cycle - (the preset number of queries + the number of requests on the previous page - the number of queries in the previous small cycle - 1). Otherwise, all the data of this cycle will be found out and the cycle will continue to move forward until the query data meets the preset number of queries or the small cycle query start time is less than the global query start time.
[0030] In some embodiments, the method further comprises: in order to update the paging parameters,
[0031] Determine whether the middle node of the previous page appears;
[0032] If the current query number is greater than the previous page request number for the first time, the small cycle query start time is updated to the current small cycle start time, the small cycle data index identifier is updated to the total number of the current small cycle - (the previous page request number - the current query number) + 1, and the global data index identifier is updated to the global data index identifier - the previous page request number.
[0033] In some embodiments, the method further comprises:
[0034] In response to a page query request, when scrolling in reverse order and querying the home page data, the target data source is queried in a small period query time range: from the end date - the preset time span to the end date.
[0035] In some embodiments, the method further comprises:
[0036] In response to a page query request, when the data is queried in reverse order and from the last page, the time range of the target data source in the small cycle query is queried: from the start date to the start date + the preset time span.
[0037] In a second aspect, an embodiment of the present application further provides a data paging query device, wherein the device comprises:
[0038] A response module is used to respond to a page query request and query the time range of the target data source in a small cycle query when flipping back in order and querying the home page data;
[0039] A calculation module, used to calculate the total number of queries according to the time range of the target data source in the small cycle query;
[0040] A reduction module, used for reducing the time range of the target data source in the small cycle query when the total number of queries exceeds a preset threshold, to obtain an adjusted time range of the target data source in the small cycle query;
[0041] A first query module, configured to query from a small-cycle data index identifier based on the adjusted time range of the target data source in the small-cycle query, and return a query result;
[0042] The second query module is used to start the query using the small cycle query start time and small cycle data index identifier recorded on the previous page when flipping forward in positive order and querying the first page data, and return the query result.
[0043] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the above method.
[0044] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes the above method.
[0045] At least one of the above technical solutions adopted in the embodiment of the present application can achieve the following beneficial effects: in response to a page query request, when the target data source is queried in the time range of the small cycle query when the positive sequence is turned back and the home page data is queried, then the total number of queries is calculated according to the time range of the target data source in the small cycle query, and then when the total number of queries exceeds the preset threshold, the time range of the target data source in the small cycle query is narrowed to obtain the adjusted time range of the target data source in the small cycle query. Finally, based on the adjusted time range of the target data source in the small cycle query, the query is started from the small cycle data index identifier, and the query result is returned. Alternatively, when the positive sequence is turned forward and the home page data is queried, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used to start the query, and the query result is returned. Through the above method, in the scenario where the data is unevenly distributed according to the time dimension, the time period partition and the window contraction method are used to reduce the total amount of data in the current query cycle, so as to achieve the functional effect that the query return time of each page is not affected by the query depth and the query performance is stable even in the scenario where the query time span is large, the data distribution is uneven and the data volume is large. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0047] Figure 1 This is a flow chart of a data paging query method in an embodiment of the present application;
[0048] Figure 2 This is a schematic diagram of the forward sequence in the embodiment of the present application;
[0049] Figure 3 This is a schematic diagram of forward flipping in the positive sequence in the embodiment of the present application;
[0050] Figure 4 This is a schematic diagram of the reverse order of the embodiment of the present application;
[0051] Figure 5 This is a schematic diagram of reverse forward flipping in the embodiment of the present application;
[0052] Figure 6 This is a schematic diagram of the implementation process of turning the page backward in the embodiment of the present application;
[0053] Figure 7 This is a schematic diagram of the implementation process of turning the page forward in the embodiment of the present application;
[0054] Figure 8 This is a schematic diagram of the structure of a data paging query device in an embodiment of the present application;
[0055] Fig. 9 It is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0057] At present, if a customer needs to query n data from the database and requires that m data be displayed per page, the customer can browse a total of [n / m] pages of data, and the last page only displays n%m data. As the amount of data queried by customers increases, the efficiency of data query per page decreases, and the problem of deep paging becomes significant. However, due to the particularity of the database, the complexity of the implementation process of paging data query is determined. Here, MySQL database is taken as an example. This database uses the TOP method for data query. When the user queries the n1 to n2 data from the database, the database will first query the first n2 data, and then sort the first n2 data according to a certain field and intercept the n1 to n2 data, so as to achieve the purpose of data paging. Therefore, in most cases, the amount of data queried from the database will be much larger than the actual request of the user, and even the full amount of data that meets the conditions will be queried for paging, resulting in a great waste of resources and timeout of returned data.
[0058] During research, the inventor discovered that in order to improve the efficiency of data query, a method and terminal for improving the efficiency of deep paging query of a database are provided. First, business data is read from an original data table according to preset business conditions. Then, the business data is sequentially written into multiple sub-tables according to preset sub-table data thresholds. Next, the target sub-table number and data offset of the sub-table where the target data is stored are calculated according to the page number and page capacity contained in the paging query request. Finally, the target data is queried by directly locating the sub-table where the target data is located according to the sub-table information.
[0059] In other solutions, deep paging and fast query technology for massive time series data is used, which adopts the method of statistics first and then query. By moving the start and end intervals of each query, the query interval where the data to be queried is located is accurately located, reducing the amount of data calculation and improving the query speed of time series data in time aggregation.
[0060] In other solutions, in order to reduce the result set of each query, a paging query method between B / S partitions for time-intensive and large data volumes is used. The time conditions are recorded by storing the start time and end time of each page query in a cache file, and the data of the page is queried from the database and returned according to the time conditions, thereby realizing the database query through partitioned tables, and then splicing them according to time points to obtain the final results.
[0061] For systems that require paging queries for large amounts of data, existing technologies mainly address the problem of reduced query efficiency caused by deep paging by narrowing the range of data that needs to be queried. However, existing paging query technologies still have the following disadvantages:
[0062] In a method and terminal for improving the efficiency of deep paging query of a database, the interval range of data is located by creating a sub-table for the data or adding a page number field to the data record. This requires presetting business conditions, resulting in inflexible data paging and the consumption of a large amount of additional storage resources.
[0063] In the deep paging fast query technology for massive time series data, the query interval where the data is located is searched by first counting and then querying in a small interval. Each time the search needs to start from the start or end time, additional search time needs to be added to the query time. The length of the search time is related to the size of the query interval. If the size of the query interval is only adjusted by the query depth, when the data is unevenly distributed in time series, the problem of deep paging is also difficult to avoid.
[0064] In a paging query method for B / S partitions with a large amount of time-intensive data, recording the time conditions by storing the start time and end time of each page query in a cache file will occupy a large amount of storage resources, and during the initial query, it is necessary to rely on the shortest time interval between two data, all time points in the interval and other parameters to calculate the start and end time points of the next page query, which also requires a lot of computing time. When the data is sparsely distributed in time series, the query performance is not significantly improved.
[0065] Through the method in the embodiment of the present application, when the total data volume of the paging query time series data is large and the data distribution is uneven, the time consumption of a single query can be reduced to avoid the problem of reduced query efficiency caused by deep paging, thereby making the system's single query performance tend to be stable.
[0066] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0067] The present application embodiment provides a data paging query method, such as Figure 1 As shown, a schematic diagram of a data paging query method in an embodiment of the present application is provided, and the method at least includes the following steps S110 to S150:
[0068] It should be noted that when introducing data paging query, data source A is taken as an example. Data source A can be considered as the data source of massive query.
[0069] Specifically, the query time range is [beginDate, endDate], and the time span of a single query cycle is singleCycleDate (here 30 days). It can be understood that the time span of a single query cycle can be configured according to actual conditions and is not limited to the protection scope in the embodiments of the present application.
[0070] The time range of the small cycle query is [startDateAn, dlineDateAn), and 10 data are displayed per page (adjustable according to actual conditions). Displaying 10 data per page can be configured according to actual conditions and is not limited to the protection scope in the embodiments of the present application.
[0071] The global start and end time is divided into multiple small periods to calculate the total number of entries totalNum through parallel query. The global data index is identified as dbQueryIndex.
[0072] Each small period data index is identified as nextQueryIndex, and each small period query start time is nextQueryDate.
[0073] For the global data index of the current request, indexNo, when indexNo is greater than dbQueryIndex, it can be determined as a next page turn, and when indexNo is less than dbQueryIndex, it can be determined as a previous page turn.
[0074] It should be noted that, unless otherwise specified, the following detailed description is based on an example where 10 data items are displayed per page and a single query cycle time is 30 days.
[0075] Step S110, in response to the page query request, query the time range of the target data source in the small cycle query when flipping back in positive order and querying the home page data.
[0076] In response to a page query request, you first need to query the time range of the target data source in the small cycle query when you query the home page data. That is, when querying the home page data, the small cycle time range of the query data source A is [startDateA1, dlineDateA1) is [beginDate, beginDate+30).
[0077] At this time, each small cycle data index identifier nextQueryIndex is initialized to 1, and the global data index identifier dbQueryIndex is initialized to 0.
[0078] Step S120, calculating the total number of queries according to the time range of the target data source in the small cycle query.
[0079] According to the time range of the target data source in the small cycle query, the total number of [beginDate, beginDate+30) is calculated.
[0080] Step S130, when the total number of queries exceeds a preset threshold, narrowing the time range of the small-cycle query of the target data source to obtain an adjusted time range of the small-cycle query of the target data source.
[0081] First, calculate the total number of records in [beginDate, beginDate+30). If the total number exceeds the threshold, it is considered that the data in this time range is densely distributed. At this time, the query interval is reduced to half of the original [beginDate, beginDate+15), until the total number of small cycle data is less than the threshold or the start and end time of the small cycle are on the same day, that is, the data of a certain day has exceeded the threshold. This will avoid intensive queries.
[0082] By flexibly adjusting the size of the small cycle according to the data distribution, that is, automatically shrinking the window size, the deep paging problem in scenarios with dense data distribution can be effectively avoided.
[0083] At the same time, in small-cycle partition queries, the pages can be flexibly turned forward and backward through periodic movement, and the global arrangement order of the queried data can be ensured, ensuring that the data with the same page number is displayed consistently when turning the page forward and backward, thereby ensuring a customer-free experience in periodic queries.
[0084] Step S140 , based on the adjusted time range of the target data source in the small-cycle query, start querying from the small-cycle data index identifier and return the query result.
[0085] After adjusting the window size, first query 10 data from nextQueryIndex. If the current small cycle can query 10 data for page display, update nextQueryIndex to nextQueryIndex+10, update dbQueryIndex to dbQueryIndex+10, and the start time of the small cycle query is still recorded as startDateA1. It should be noted that beginDate is taken here.
[0086] Step S150, or, when flipping forward in positive order and querying the home page data, use the small cycle query start time and small cycle data index identifier recorded on the previous page to start the query, and return the query result.
[0087] If the page query accesses the database for the first time, cross-cycle processing is not performed first, and the small cycle query start time nextQueryDate recorded on the previous page and the small cycle data index identifier nextQueryIndex are used.
[0088] Similarly, when flipping forward in positive order and querying the data on the first page, it is necessary to query based on the small cycle query start time and small cycle data index identifier recorded on the previous page, and return the query results.
[0089] Through the above method, by designing the small cycle query start time nextQueryDate, the small cycle data index identifier nextQueryIndex, the global data index identifier dbQueryIndex, and the total number of totalNum, four special paging parameters can quickly retrieve the small interval range where the next page data is located, reduce the search time for the next page data and the total amount of a single data query, so as to avoid the deep paging problem that is prone to occur in the global query, thereby improving the query efficiency, and the above-mentioned small cycle query start time nextQueryDate, small cycle data index identifier nextQueryIndex, global data index identifier dbQueryIndex, and total number of totalNum are retained in the cache each time.
[0090] In one embodiment of the present application, the method also includes: when flipping back in positive order and querying non-home page data, using the small cycle query start time and the small cycle data index identifier recorded on the previous page; determining the small cycle time span based on the small cycle query start time recorded on the previous page, and displaying the page according to the data of the small cycle data index identifier; if the number of data items when the page is displayed according to the data of the small cycle data index identifier does not meet the preset query number, moving the small cycle for data query.
[0091] like Figure 2 As shown, when querying non-homepage data, cross-cycle processing is not performed first, and the small-cycle query start time nextQueryDate recorded on the previous page and the small-cycle data index identifier nextQueryIndex are used.
[0092] That is to say, under normal circumstances, the query small cycle time span is
[0093] [nextQueryDate, nextQueryDate+30), when nextQueryDate+30 is greater than endDate, the small cycle time span is [nextQueryDate, endDate],
[0094] The data index is [nextQueryIndex, nextQueryIndex+10) and is displayed on the page.
[0095] If the current small cycle has less than 10 data, the method of moving the small cycle to query data is the same.
[0096] In one embodiment of the present application, the time range of the small cycle query based on the adjusted target data source is started from the small cycle data index identifier, and the query result is returned, including: when starting the query from the small cycle data index identifier, it is determined whether the current small cycle has queried a preset number of queries; if so, the small cycle data index identifier is updated to the small cycle data index identifier + the preset number of queries, and the global data index identifier is updated to the global data index identifier + the preset number of queries and the start time of the small cycle query remains unchanged; when starting the query from the small cycle data index identifier, it is determined whether the current small cycle has queried n1 data and n1 is less than the preset number of queries, then the time range of the mobile small cycle query is the first time; when starting the query from the small cycle data index identifier, it is determined whether the current small cycle satisfies the preset number of queries - n1 data; if satisfied, the small cycle is updated. The small cycle data index identifier is the small cycle data index identifier + preset query number - n1, the global data index identifier is updated to the global data index identifier + preset query number, and the small cycle query start time is updated to the second time; if it is not satisfied, all the data of the current small cycle will be queried and the time range of the small cycle query will continue to be moved; when starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1-n2 data; if it is satisfied, update the small cycle data index identifier to the small cycle data index identifier + preset query number - n1-n2, update the global data index identifier to the global data index identifier + preset query number, and the small cycle query start time is the third time; if it is not satisfied, continue to move the small cycle until the current query number meets the preset query number or the small cycle end time is greater than the global query end time.
[0097] like Figure 2 As shown, after adjusting the window size, first query 10 data starting from nextQueryIndex,
[0098] If the current small cycle can query 10 data for page display, then update nextQueryIndex to nextQueryIndex+10, update dbQueryIndex to dbQueryIndex+10, and the start time of the small cycle query is still recorded as startDateA1 (beginDate is taken here).
[0099] Optionally, if n1 data are queried in the current small cycle and n1 is less than 10, then it is necessary to move the small cycle [startDateA2, dlineDateA2) to [dlineDateA1, dlineDateA1+30), and after moving the small cycle, nextQueryIndex is 1, and 10-n1 data are queried in the current small cycle.
[0100] Optionally, if the current small cycle satisfies 10-n1 data, nextQueryIndex is updated to nextQueryIndex+10-n1, dbQueryIndex is updated to dbQueryIndex+10, and the small cycle query start time is updated from startDateA1 to startDateA2.
[0101] Optionally, if the current small cycle does not satisfy 10-n1 data, all n2 data of the current small cycle are queried, and the small cycle [startDateA3, dlineDateA3) is continued to be moved to [dlineDateA2, dlineDateA2+30). After the small cycle is moved, nextQueryIndex is 1.
[0102] Optionally, if the current small cycle meets 10-n1-n2 data, update nextQueryIndex to nextQueryIndex+10-n1-n2, update dbQueryIndex to dbQueryIndex+10, and update the small cycle query start time from startDateA2 to startDateA3. Otherwise, continue to move the small cycle until the number of queries meets 10 or the small cycle end time is greater than the global query end time endDate, then end the small cycle movement.
[0103] It can be understood that the first time, the second time and the third time mentioned above are startDate.
[0104] It should be noted that the preset number of queries is 30 days, which can be selected according to actual conditions. The preset number of queries is 10, which can also be configured according to actual conditions and is not specifically limited in the embodiments of the present application.
[0105] In one embodiment of the present application, when flipping forward in positive order and querying the home page data, the query is started using the small cycle query start time and the small cycle data index identifier recorded on the previous page, and the query result is returned, including: when the query is started using the small cycle data index identifier recorded on the previous page, it is determined whether each small cycle data index identifier - 1 meets the preset query number + the previous page request number; if it meets the requirements, the data of the current small cycle query data index is displayed on the page, the small cycle data index identifier is updated to the small cycle data index identifier - the previous page request number, and the global data index identifier is updated to the global data index identifier - the previous page request number. The number of items and the start time of the small cycle query remain unchanged; if not satisfied, all the remaining items in the current small cycle will be found out, the small cycle will be moved forward, and the total number of small cycle data after the move will be calculated to determine whether it meets the preset query number + the number of requests on the previous page - the number of items remaining in the current small cycle; if satisfied, the query current small cycle index is the total number of the current small cycle - (preset query number + number of requests on the previous page - number of queries in the previous small cycle - 1) data, otherwise all the data in this cycle will be found out and the cycle will continue to move forward until the query data meets the preset query number or the small cycle query start time is less than the global query start time, and the query is terminated.
[0106] like Figure 3 As shown in the figure, since the current displayed page needs to be skipped when turning the page forward, the number of queries is the number of requests for this page (10) + the number of requests for the previous page (lastSize). Considering the number of requests for the previous page, 10 is generally used for non-homepage pages, but if it is the last page, there may be less than 10. When turning the page forward, it is equivalent to querying two pages at a time, and the start time and index of the small cycle are required, and the starting point of the next page queried by the current page.
[0107] First, determine whether the number of data items to be queried in the current week, nextQueryIndex-1, meets 10+lastSize items:
[0108] Optionally, if the condition is met, the data index is queried from the current small period.
[0109] [nextQueryIndex-10-lastSize, nextQueryIndex-lastSize) data is displayed on the page, nextQueryIndex is updated to nextQueryIndex-lastSize, dbQueryIndex is updated to dbQueryIndex-lastSize, and the start time of the small cycle query is still nextQueryDate.
[0110] Optionally, if it does not meet the requirement, all the remaining data in the current small cycle (currentQry) are checked, that is, the data index is [1, nextQueryIndex), and then the small cycle is moved forward, and the total number of data in the small cycle after the move (singleTotalNum) is calculated to determine whether it meets 10+lastSize-currentQry.
[0111] Optionally, if satisfied, query the current small cycle index as
[0112] [singleTotalNum-(10+lastSize-currentQry)+1,singleTotalNum] data, otherwise all the data in this cycle will be found and the cycle will continue to move forward until the query data meets 10 or the small cycle query start time nextQueryDate is less than the global query start time beginDate and the query ends.
[0113] In one embodiment of the present application, the method also includes: in order to update the paging parameters, determining whether the previous page intermediate node appears; if the current query number is greater than the previous page request number for the first time, updating the small cycle query start time to the current small cycle start time, updating the small cycle data index identifier to the total number of the current small cycle - (the previous page request number - the current query number) + 1, and updating the global data index identifier to the global data index identifier - the previous page request number.
[0114] Preferably, in order to update the paging parameters, it is necessary to determine whether the intermediate node of the previous page appears, that is, when the current query number currentQry is greater than lastSize for the first time, update nextQueryDate to the start time of the current small cycle, update nextQueryIndex to the total number of the current small cycle - (lastSize - the current number of queries) + 1, and update dbQueryIndex to dbQueryIndex-lastSize.
[0115] In one embodiment of the present application, the method further includes: in response to a page query request, when flipping in reverse order and querying home page data, querying the target data source in a small cycle query time range: from end date - preset time span to end date.
[0116] like Figure 4As shown, reverse order: when querying the home page data, the small cycle time range [startDateA1, dlineDateA1) of the query data source A is initialized to [endDate-30, endDate), nextQueryIndex is initialized to 1, dbQueryIndex is initialized to 0, and the subsequent query method is the same as the aforementioned forward order.
[0117] In one embodiment of the present application, the method further includes: in response to a page query request, when flipping forward in reverse order and querying data from the last page, querying the target data source in a small cycle query time range: from the start date to the start date + a preset time span.
[0118] like Figure 5 As shown, flip forward in reverse order: when flipping forward from the last page, the small cycle time range [startDateAn, dlineDateAn) of the query data source A is [beginDate, beginDate+30), and the subsequent query method is the same as the aforementioned forward flipping in forward order.
[0119] However, since 10+lastSize pieces of data need to be queried and intercepted when turning the page forward, each forward query needs to flip the data queried in each small period and then splice it. When the final data is processed, turning the page forward in positive order requires flipping all the queried data first and then intercepting the first 10 pieces of data, while turning the page forward in reverse order requires first intercepting 10 pieces of data and then flipping and displaying them.
[0120] like Figure 6 As shown in FIG. 1 , it is a schematic diagram of the implementation process of turning the page backward in the embodiment of the present application.
[0121] Get the next index n of the previous page and query the entries n to n+10 of the current cycle.
[0122] Determine whether the number of entries is sufficient. If not, the date processing (moving back one period) cannot span the original period.
[0123] Determine whether the number of entries is sufficient. If so, record the position of the last data entry and update the index mark.
[0124] like Figure 7 , which is a schematic diagram of the implementation process of turning the page forward in the embodiment of the present application,
[0125] Get the current index of the previous page and determine whether the number of index entries is greater than 10. If so, find out n-10 to n entries in the current cycle.
[0126] If not, query the previous n data in the current cycle. Date processing (moving forward one cycle) cannot cross the original cycle.
[0127] Find out all the data of the new cycle and determine whether the number of data is sufficient. If so, intercept the last 10-n data of the new cycle, record the location and update the index mark.
[0128] In one embodiment of the present application, the first query module 840 is also used to
[0129] When flipping backward in positive order and querying data other than the first page, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used;
[0130] Determine the small cycle time span according to the small cycle query start time recorded on the previous page, and display the data on the page according to the small cycle data index identifier;
[0131] If the number of data items displayed on the page according to the data identified by the small-cycle data index does not meet the preset query number, the small cycle is moved to perform data query.
[0132] In one embodiment of the present application, the first query module 840 is also used to
[0133] When starting to query from the small cycle data index identifier, determine whether the current small cycle has queried the preset number of query items;
[0134] If yes, update the small-cycle data index identifier to the small-cycle data index identifier + the preset number of queries, update the global data index identifier to the global data index identifier + the preset number of queries, and keep the small-cycle query start time unchanged;
[0135] When starting the query from the small cycle data index identifier, it is determined whether n1 pieces of data are queried in the current small cycle and n1 is less than the preset number of query pieces, and the time range of the mobile small cycle query is the first time;
[0136] When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1 data;
[0137] If satisfied, update the small cycle data index identifier to the small cycle data index identifier + the preset query number - n1, update the global data index identifier to the global data index identifier + the preset query number, and update the small cycle query start time to the second time;
[0138] If it is not satisfied, all data of the current small cycle will be queried and the time range of the small cycle query will continue to move;
[0139] When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1-n2 data;
[0140] If satisfied, the small cycle data index identifier is updated to the small cycle data index identifier + the preset query number - n1-n2, the global data index identifier is updated to the global data index identifier + the preset query number, and the small cycle query start time is updated to the third time;
[0141] If not, continue to move the small cycle until the number of queries this time meets the preset number of queries or the end time of the small cycle is greater than the end time of the global query.
[0142] In one embodiment of the present application, the first query module 840 is also used to
[0143] When starting a query using the small cycle data index identifier recorded on the previous page, determine whether each small cycle data index identifier - 1 satisfies the preset query number + the previous page request number;
[0144] If satisfied, the data of the current small cycle data index is queried for page display, the small cycle data index identifier is updated to the small cycle data index identifier-the number of requests on the previous page, and the global data index identifier is updated to the global data index identifier-the number of requests on the previous page, and the small cycle query start time remains unchanged;
[0145] If not, all the remaining numbers of the current small cycle are checked, the small cycle is moved forward, and the total number of small cycle data after the movement is calculated to determine whether the preset query number + the number of requests on the previous page - the number of remaining numbers of the current small cycle is met;
[0146] If it is satisfied, query the data of the current small cycle index as the total number of the current small cycle - (preset query number + previous page request number - previous small cycle query number - 1); otherwise, find out all the data of this cycle and continue to move forward the cycle until the query data meets the preset query number or the small cycle query start time is less than the global query start time.
[0147] In one embodiment of the present application, a paging parameter updating module is also included for
[0148] Determine whether the middle node of the previous page appears;
[0149] If the current query number is greater than the previous page request number for the first time, the small cycle query start time is updated to the current small cycle start time, the small cycle data index identifier is updated to the total number of the current small cycle - (the previous page request number - the current query number) + 1, and the global data index identifier is updated to the global data index identifier - the previous page request number.
[0150] In one embodiment of the present application, a post-order flip module is also included for
[0151] In response to a page query request, when scrolling in reverse order and querying the home page data, the target data source is queried in a small period query time range: from the end date - the preset time span to the end date.
[0152] In one embodiment of the present application, it also includes reverse forward flipping, for
[0153] In response to a page query request, when the data is queried in reverse order and from the last page, the time range of the target data source in the small cycle query is queried: from the start date to the start date + the preset time span.
[0154] The present application embodiment also provides a data paging query device 800, such as Figure 8 As shown, a schematic diagram of the structure of a data paging query device in an embodiment of the present application is provided, wherein the data paging query device 800 at least includes: a response module 810, a calculation module 820, a reduction module 830, a first query module 840 and a second query module 850, wherein:
[0155] In one embodiment of the present application, the acquisition module 810 is specifically used to: respond to a page query request, query the time range of the target data source in a small cycle query when flipping back in positive order and querying the home page data.
[0156] In response to a page query request, you first need to query the time range of the target data source in the small cycle query when you query the home page data. That is, when querying the home page data, the small cycle time range of the query data source A is [startDateA1, dlineDateA1) is [beginDate, beginDate+30).
[0157] At this time, each small cycle data index identifier nextQueryIndex is initialized to 1, and the global data index identifier dbQueryIndex is initialized to 0.
[0158] In one embodiment of the present application, the acquisition module 820 is specifically used to calculate the total number of queries according to the time range of the target data source in the small cycle query.
[0159] According to the time range of the target data source in the small cycle query, the total number of [beginDate, beginDate+30) is calculated.
[0160] In one embodiment of the present application, the acquisition module 830 is specifically used to: when the total number of queries exceeds a preset threshold, narrow the time range of the target data source in the small cycle query to obtain an adjusted time range of the target data source in the small cycle query.
[0161] First, calculate the total number of records in [beginDate, beginDate+30). If the total number exceeds the threshold, it is considered that the data in this time range is densely distributed. At this time, the query interval is reduced to half of the original [beginDate, beginDate+15), until the total number of small cycle data is less than the threshold or the start and end time of the small cycle are on the same day, that is, the data of a certain day has exceeded the threshold. This will avoid intensive queries.
[0162] By flexibly adjusting the size of the small cycle according to the data distribution, that is, automatically shrinking the window size, the deep paging problem in scenarios with dense data distribution can be effectively avoided.
[0163] At the same time, in small-cycle partition queries, the pages can be flexibly turned forward and backward through periodic movement, and the global arrangement order of the queried data can be ensured, ensuring that the data with the same page number is displayed consistently when turning the page forward and backward, thereby ensuring a customer-free experience in periodic queries.
[0164] In one embodiment of the present application, the acquisition module 840 is specifically used to: start querying from a small-cycle data index identifier based on the adjusted time range of the target data source in the small-cycle query, and return the query result.
[0165] After adjusting the window size, first query 10 data from nextQueryIndex. If the current small cycle can query 10 data for page display, update nextQueryIndex to nextQueryIndex+10, update dbQueryIndex to dbQueryIndex+10, and the start time of the small cycle query is still recorded as startDateA1. It should be noted that beginDate is taken here.
[0166] In one embodiment of the present application, the acquisition module 850 is specifically used to: when flipping forward in positive order and querying the home page data, use the small cycle query start time and small cycle data index identifier recorded on the previous page to start the query and return the query result.
[0167] If the page query accesses the database for the first time, cross-cycle processing is not performed first, and the small cycle query start time nextQueryDate recorded on the previous page and the small cycle data index identifier nextQueryIndex are used.
[0168] Similarly, when flipping forward in positive order and querying the data on the first page, it is necessary to query based on the small cycle query start time and small cycle data index identifier recorded on the previous page, and return the query results.
[0169] It can be understood that the above-mentioned data paging query device can implement each step of the data paging query method provided in the above-mentioned embodiment, and the relevant explanations about the data paging query method are applicable to the data paging query device, which will not be repeated here.
[0170] Fig. 9 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Fig. 9 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0171] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0172] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0173] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data paging query device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0174] In response to a page query request, when flipping back in order and querying the home page data, query the time range of the target data source in the small cycle query;
[0175] Calculate the total number of queries based on the time range of the target data source in the small cycle query;
[0176] When the total number of queries exceeds a preset threshold, the time range of the small-cycle query of the target data source is narrowed to obtain an adjusted time range of the small-cycle query of the target data source;
[0177] Based on the adjusted time range of the target data source in the small cycle query, start querying from the small cycle data index identifier and return the query result;
[0178] Alternatively, when flipping forward in positive order and querying the first page data, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used to start the query and return the query results.
[0179] The above application Figure 1 The method performed by the data paging query device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0180] The electronic device may also perform Figure 1 The method for executing the data paging query device in the Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0181] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method executed by the data paging query device in the embodiment shown is specifically used to execute:
[0182] In response to a page query request, when flipping back in order and querying the home page data, query the time range of the target data source in the small cycle query;
[0183] Calculate the total number of queries based on the time range of the target data source in the small cycle query;
[0184] When the total number of queries exceeds a preset threshold, the time range of the small-cycle query of the target data source is narrowed to obtain an adjusted time range of the small-cycle query of the target data source;
[0185] Based on the adjusted time range of the target data source in the small cycle query, start querying from the small cycle data index identifier and return the query result;
[0186] Alternatively, when flipping forward in positive order and querying the first page data, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used to start the query and return the query results.
[0187] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0188] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0189] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0190] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0191] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0192] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0193] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0194] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0195] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0196] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A data paging query method, wherein: The method comprises: In response to a page query request, when flipping back in order and querying the home page data, query the time range of the target data source in the small cycle query; Calculate the total number of queries based on the time range of the target data source in the small cycle query; When the total number of queries exceeds a preset threshold, the time range of the small-cycle query of the target data source is narrowed to obtain an adjusted time range of the small-cycle query of the target data source; Based on the adjusted time range of the target data source in the small cycle query, start querying from the small cycle data index identifier and return the query result; Alternatively, when flipping forward in positive order and querying the first page data, the small cycle query start time and the small cycle data index identifier recorded on the previous page are used to start the query and return the query results.
2. The method of claim 1, wherein: The method further comprises: when flipping back in positive order and querying non-homepage data, using the small cycle query start time and the small cycle data index identifier recorded on the previous page; Determine the small cycle time span according to the small cycle query start time recorded on the previous page, and display the data on the page according to the small cycle data index identifier; If the number of data items displayed on the page according to the data identified by the small-cycle data index does not meet the preset query number, the small cycle is moved to perform data query.
3. The method of claim 2, wherein: The query based on the adjusted time range of the target data source in the small cycle query starts from the small cycle data index identifier, and returns the query result, including: When starting to query from the small cycle data index identifier, determine whether the current small cycle has queried the preset number of query items; If yes, update the small-cycle data index identifier to the small-cycle data index identifier + the preset number of queries, update the global data index identifier to the global data index identifier + the preset number of queries, and keep the small-cycle query start time unchanged; When starting the query from the small cycle data index identifier, it is determined whether n1 pieces of data are queried in the current small cycle and n1 is less than the preset number of query pieces, and the time range of the mobile small cycle query is the first time; When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1 data; If satisfied, update the small cycle data index identifier to the small cycle data index identifier + the preset query number - n1, update the global data index identifier to the global data index identifier + the preset query number, and update the small cycle query start time to the second time; If it is not satisfied, all data of the current small cycle will be queried and the time range of the small cycle query will continue to move; When starting the query from the small cycle data index identifier, determine whether the current small cycle meets the preset query number - n1-n2 data; If satisfied, the small cycle data index identifier is updated to the small cycle data index identifier + the preset query number - n1-n2, the global data index identifier is updated to the global data index identifier + the preset query number, and the small cycle query start time is updated to the third time; If not, continue to move the small cycle until the number of queries this time meets the preset number of queries or the end time of the small cycle is greater than the end time of the global query.
4. The method of claim 1, wherein: When you scroll forward in positive order and query the data on the first page, use the small cycle query start time and small cycle data index identifier recorded on the previous page to start the query and return the query results, including: When starting a query using the small cycle data index identifier recorded on the previous page, determine whether each small cycle data index identifier - 1 satisfies the preset query number + the previous page request number; If satisfied, the data of the current small cycle data index is queried for page display, the small cycle data index identifier is updated to the small cycle data index identifier-the number of requests on the previous page, and the global data index identifier is updated to the global data index identifier-the number of requests on the previous page, and the small cycle query start time remains unchanged; If not, all the remaining numbers of the current small cycle are checked, the small cycle is moved forward, and the total number of small cycle data after the movement is calculated to determine whether the preset query number + the number of requests on the previous page - the number of remaining numbers of the current small cycle is met; If it is satisfied, the query of the current small cycle index is the total number of the current small cycle - (preset query number + previous page request number - previous small cycle query number - 1), otherwise all the data of this cycle will be found and the cycle will continue to move forward until the query data meets the preset query number or the small cycle query start time is less than the global query start time.
5. The method of claim 4, wherein: The method further comprises: in order to update the paging parameters, Determine whether the middle node of the previous page appears; If the current query number is greater than the previous page request number for the first time, the small cycle query start time is updated to the current small cycle start time, the small cycle data index identifier is updated to the total number of the current small cycle - (the previous page request number - the current query number) + 1, and the global data index identifier is updated to the global data index identifier - the previous page request number.
6. The method of claim 1, wherein: The method further comprises: In response to a page query request, when scrolling in reverse order and querying the home page data, the target data source is queried in a small period query time range: from the end date - the preset time span to the end date.
7. The method of claim 1, wherein: The method further comprises: In response to a page query request, when the data is queried in reverse order and from the last page, the time range of the target data source in the small cycle query is queried: from the start date to the start date + the preset time span.
8. A data paging query device, wherein: The device comprises: A response module is used to respond to a page query request and query the time range of the target data source in a small cycle query when flipping back in order and querying the home page data; A calculation module, used to calculate the total number of queries according to the time range of the target data source in the small cycle query; A reduction module, used for reducing the time range of the target data source in the small cycle query when the total number of queries exceeds a preset threshold, to obtain an adjusted time range of the target data source in the small cycle query; A first query module, configured to query from a small-cycle data index identifier based on the adjusted time range of the target data source in the small-cycle query, and return a query result; The second query module is used to start the query using the small cycle query start time and small cycle data index identifier recorded on the previous page when flipping forward in positive order and querying the first page data, and return the query result.
9. An electronic device, comprising: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 7.
10. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, causes the electronic device to execute any one of the methods of claims 1 to 7.
Citation Information
Patent Citations
Method for interval and paging query of time-intensive B / S (Browser / Server) with large data size
CN102880685A
Paging query method and device and electronic equipment
CN111506600A
Paging query method and device, storage medium and electronic equipment
CN113946725A
