Multi-table query pagination methods, devices and electronic equipment
By obtaining query requests from HBase, identifying the target table, and using the target data identifiers in the cache for data filtering and sorting, the problem of low efficiency in multi-table join queries in HBase is solved, achieving faster query speed and higher query efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA CONSTRUCTION BANK
- Filing Date
- 2023-06-15
- Publication Date
- 2026-08-04
AI Technical Summary
HBase queries struggle to differentiate data from different query requests, resulting in low query efficiency and an inability to effectively join multiple tables for combined queries.
By obtaining query requests, determining the target table, and using the target data identifiers in the cache for data filtering and sorting, feedback data is generated. Concurrent queries and global sorting methods are used to improve query efficiency.
It effectively distinguishes the target data for different query requests, speeds up multi-table queries, and improves query efficiency.
Smart Images

Figure CN116680317B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data querying, and in particular to a multi-table query pagination method, apparatus, and electronic device. Background Technology
[0002] Among related technologies, HBase, as a massive data storage engine, provides the ability to quickly and randomly access ultra-large amounts of data, solving the problems of storage difficulties and low access efficiency faced by traditional databases. As one of the big data components, HBase is increasingly widely used in enterprises. It can retrieve data by rowkey or rowkey range, achieving millisecond-level query responses for hundreds of billions or even trillions of data points. However, currently, it is difficult to distinguish the data retrieved by different query requests during HBase queries, which can lead to incorrect data being retrieved and reduce query efficiency. Summary of the Invention
[0003] This disclosure provides a multi-table query pagination method, apparatus, and electronic device to at least solve the problem in related technologies where multiple tables cannot be linked for joint queries. The technical solution of this disclosure is as follows: According to a first aspect of the present disclosure, a multi-table query pagination method is provided, including: Obtain a query request and determine at least one target table based on the query request; Determine the target data in the cache that corresponds to the query request; The target data is queried according to the query request to obtain feedback data, and a response message is generated based on the feedback data.
[0004] Optionally, the query request includes a service interface ID, request parameters, and a tracking ID, and the query request includes query conditions, sorting fields, number of pages to query, and number of records per page.
[0005] Optionally, the step of determining the target table based on the query request specifically includes: The service retrieval method obtains at least one target table name based on the service interface ID, and the table corresponding to the target table name is the target table.
[0006] Optionally, the step of determining the target data in the cache corresponding to the query request specifically includes: Obtain the target identifier based on the request parameters and tracking ID; If target data carrying the target identifier exists in the cache, then the target data is retrieved; If the target data carrying the target identifier does not exist in the cache, the target table is queried according to the request parameters to obtain the target data.
[0007] Optionally, the step of querying the target table based on the request parameters to obtain the target data specifically includes: Concurrently query all the target tables, and add the data of each page of the target tables to the cache according to the number of pages and the number of records per page; Within the cache, the data of each of the target tables is globally sorted according to the sorting field to generate the target data.
[0008] Optionally, the step of adding the data of each page in the target table to the cache sequentially according to the query page number and the number of records per page specifically includes: The page to be queried in each target table is determined based on the number of pages to be queried. Data is selected from the page to be queried based on the number of items per page and added to the cache.
[0009] Optionally, the step of querying the target data according to the query request to obtain feedback data specifically includes: The target data is filtered according to the query conditions, and the data that meets the query conditions is determined as the feedback data; After exporting the feedback data, delete the feedback data from the cache.
[0010] Optionally, the method further includes: Determine if the next page of data exists in the cache. If the next page of data exists, end the process. If no data is available on the next page, the target table is queried according to the request parameters to obtain the target data.
[0011] Optionally, the method further includes: If data is cached for a period exceeding a preset expiration time, the data will be deleted.
[0012] According to a second aspect of the present disclosure, a multi-table query pagination apparatus is provided, comprising: The target table determination module is used to obtain a query request and determine the target table based on the query request. The target data determination module is used to determine the target data in the cache that corresponds to the query request; The response module is used to query the target data according to the query request to obtain feedback data, and generate a response message based on the feedback data.
[0013] According to a third aspect of the present disclosure, an electronic device is provided, comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of the first aspects.
[0014] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, wherein when instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the method as described in any one of the first aspects.
[0015] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method according to any one of the first aspects. The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects: The corresponding target data is determined based on the query request, thus identifying the target data to be extracted from the cache for this query request. This effectively distinguishes the target data corresponding to different query requests, speeds up the query process when performing multi-table queries, and improves query efficiency.
[0016] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0018] Figure 1 This is a flowchart illustrating a multi-table query pagination method according to an exemplary embodiment.
[0019] Figure 2 This is a flowchart illustrating a multi-table data query method according to another exemplary embodiment.
[0020] Figure 3 This is a flowchart illustrating a multi-table query pagination method according to yet another exemplary embodiment.
[0021] Figure 4 This is a block diagram illustrating a multi-table query pagination apparatus according to an exemplary embodiment.
[0022] Figure 5 This is a block diagram illustrating an apparatus according to an exemplary embodiment.
[0023] Figure 6 This is a block diagram illustrating an apparatus according to an exemplary embodiment. Detailed Implementation
[0024] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0025] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0026] It should be noted that the user information involved in this disclosure (including but not limited to user device information, user personal information, etc.) is all information authorized by the user or fully authorized by all parties.
[0027] HBase is a highly reliable, high-performance, column-oriented, scalable distributed database, an open-source implementation of Google's BigTable, primarily used to store unstructured and semi-structured loosely formatted data. The concepts involved include: Tables: HBase uses tables to organize data. Tables consist of rows and columns, and columns are divided into several column families. Rows: Each HBase table consists of several rows, and each row is identified by a row key; Column family: An HBase table is divided into a collection of many "column families". It is the basic access control unit and is created when the table is created. Column qualifiers: Data within a column family is located using column qualifiers (or columns); Cell: In an HBase table, a "cell" is defined by its row, column family, and column qualifier. Timestamp: Each cell stores multiple versions of the same data, and these versions are indexed using timestamps.
[0028] In actual business scenarios, based on product or data splitting, multiple tables may be formed. It is necessary to combine the data from multiple tables and sort and paginate them in chronological order. Since HBase only supports single-table queries, the data from multiple tables needs to be accumulated and organized into a large table to solve this problem. However, since the structure of each table is different, this approach will make the rowkey design complicated and is prone to structural chaos in actual operation.
[0029] There are two main existing methods for pagination in HBase multi-table queries: In one possible implementation, data from multiple HBase tables is accumulated into a single large HBase table, and then pagination is performed on this large table. A common implementation is to cache the last record of the previous page query, and the next page query starts from this record (excluding it).
[0030] In this embodiment, data from multiple HBase tables is accumulated into a single large HBase table. This requires consideration of the multi-source heterogeneity problem, as the structures of the multiple tables are not the same, making the model design complex. To meet the application's query needs, the common field range of the multiple tables needs to be defined in advance, making the model difficult to expand. Secondly, the rowkeys of the multiple tables are also different, making it difficult to design the rowkey when integrating them together. Finding a common rowkey for multiple tables is usually difficult.
[0031] In one possible implementation, multi-table query pagination uses the Phoenix component. Phoenix is a Structured Query Language (SQL) layer built on HBase, which allows manipulation of data on HBase using standard Java Data Connectivity (JDBC). Multi-table join queries can be implemented using the UNION ALL, ORDER BY, and LIMIT statements provided by the Phoenix SQL layer. The main idea is that when querying page n+1, the last result of page n needs to be recorded as the WHERE condition of the query statement for page n+1.
[0032] In this embodiment, multi-table queries are implemented using the Phoenix component. Phoenix solves the single-table query problem of HBase, and its support for SQL is an advantage. However, in some real-world query scenarios, SQL is not always necessary; meeting high performance requirements is key. Phoenix multi-table queries first filter each table based on conditions, then combine them using UNION ALL, and finally use ORDER BY and LIMIT to return the required number of rows for pagination. If the amount of data filtered from each table is large, performance issues arise. In addition, Phoenix's internal mechanism does not implement a robust index pushdown mechanism, and in many cases, queries require multiple interactions between the client and the server, resulting in low query performance.
[0033] Figure 1 This is a flowchart illustrating a multi-table query pagination method according to an exemplary embodiment, such as... Figure 1 As shown, the method is used in a server and includes: Step 101: Obtain a query request and determine at least one target table based on the query request.
[0034] In this embodiment, the database in the server stores HBase data. When an external application needs to query specific data, it sends a request to the server, and the server queries and filters the stored HBase tables according to the external request.
[0035] In one possible embodiment, the external query request is carried in XML message format, which includes a service interface ID, request parameters, and a trace ID. The query request includes query conditions, a sorting field, the number of pages to query (page_num), and the number of records per page (page_size). The trace ID is used to mark the correspondence between data stored in the cache and external requests. There may be multiple external requests within the same time period. To prevent data confusion between different external requests, the trace ID can be used to distinguish the external requests corresponding to the data in the cache.
[0036] Step 102: Determine the target data in the cache corresponding to the query request; In this embodiment, the cache contains data from an HBase table extracted from the database. It is necessary to determine whether the data is the target data based on the corresponding identifier.
[0037] In one possible embodiment, Message-Digest Algorithm 5 (MD5) is used as the identifier for data in the cache. The MD5 algorithm can generate a 128-bit (16-byte) hash value, also known as the MD5 value, based on data of any length, to ensure the integrity and consistency of information transmission.
[0038] In one possible embodiment, an MD5 value is generated based on the trace ID and the request parameters in the query request as an identifier for the data, and the data containing the MD5 value is the target data corresponding to the query request.
[0039] Step 103: Query the target data according to the query request to obtain feedback data, and generate a response message based on the feedback data.
[0040] In this embodiment, the query request includes query conditions. The target data in the cache is filtered according to the query conditions, and the feedback data that meets the conditions is selected. The feedback data is encapsulated into an XML response message, and the data required by the external party can be obtained. The XML response message is then fed back to the source of the query request to complete the query process.
[0041] In this embodiment, the corresponding target data is determined based on the query request, thereby determining the target data to be extracted into the cache for this query request. This effectively distinguishes the target data corresponding to different query requests, speeds up the query speed when performing multi-table queries, and improves query efficiency.
[0042] In one possible implementation, each HBase table designs its rowkey based on the characteristics of its business. It performs certain processing on the primary key of the source table. Typically, the first field of the rowkey is the user / customer identification information, such as account number. To support sorting by date / time, the date / time is usually added to the second field of the rowkey, and other business primary key information is placed after the rowkey.
[0043] Optionally, step 101, which determines the target table based on the query request, specifically includes: The service retrieval method obtains at least one target table name based on the service interface ID, and the table corresponding to the target table name is the target table.
[0044] In this embodiment, the preset service method is used to parse the parameters in the query request and obtain the service interface ID. Based on the service interface ID, multiple predefined HBase table names that need to be queried can be obtained, which are the target table names.
[0045] Optionally, the step of determining the target data in the cache corresponding to the query request specifically includes: Obtain the target identifier based on the request parameters and tracking ID; In this embodiment, each piece of data in the cache has a corresponding identifier to distinguish the data corresponding to different requests. The target identifier is obtained by performing a digest operation using the request parameters and the tracking ID.
[0046] If target data carrying the target identifier exists in the cache, then the target data is retrieved; If the target data carrying the target identifier does not exist in the cache, the target table is queried according to the request parameters to obtain the target data.
[0047] In this embodiment, multiple query requests may occur within the same time period. To prevent data confusion between different query requests, the data in the cache has a corresponding identifier to distinguish the data retrieved by different requests. For this request, if the target data carries a target identifier, it means that the data is extracted based on this query request, and it can be filtered to obtain feedback data. Otherwise, it means that the data is not extracted based on this query request, and a multi-table data query method needs to be called to retrieve the data from the HBase table in the database and store it in the cache.
[0048] Optionally, the step of querying the target table based on the request parameters to obtain the target data specifically includes: Concurrently query all the target tables, and add the data of each page of the target tables to the cache according to the number of pages and the number of records per page; Within the cache, the data of each of the target tables is globally sorted according to the sorting field to generate the target data.
[0049] This embodiment describes the specific execution process of a multi-table data query method. First, multiple target tables are queried concurrently, with one page of content retrieved each time. The query process is based on the number of pages (page_num) and the number of records per page (page_size). Page_num represents the total number of pages from all target tables to be cached, and page_size represents the number of records selected from each page of the target tables. Page_num of data is selected from the target tables, and page_size of data from each page is added to the cache. Then, all data retrieved from the cache is globally re-sorted according to the specified sorting field to generate the target data.
[0050] In one possible implementation, due to concurrent queries, the total query time equals the query time of the single longest-running HBase table. Each table retrieves one page's worth of records by default in a single query, but custom retrieval conditions can be configured. After retrieving a page of data, each table records the rowkey of the last record on the current page and places it in a cache. When querying the next page, the query can start from the next rowkey adjacent to this rowkey.
[0051] Optionally, the step of adding the data of each page in the target table to the cache sequentially according to the query page number and the number of records per page specifically includes: The page to be queried in each target table is determined based on the number of pages to be queried. Data is selected from the page to be queried based on the number of items per page and added to the cache.
[0052] Figure 2 This is a flowchart illustrating a multi-table data query method according to another exemplary embodiment. For example... Figure 2 As shown, the above multi-table data query methods are encapsulated into a general class for use by steps in the process.
[0053] Step 201: Input multiple HBase table names, which are the target table names obtained earlier.
[0054] Step 202: For the HBase tables involved in the multiple input HBase table names, data for each table is obtained through concurrent querying. The total query time is the table with the longest query time. By default, each table retrieves one page of records in one query, but the data retrieval conditions can also be customized. After each table finishes querying a page of data, it records the rowkey of the last record on the current page and places it in the cache. When querying the next page, the query can start from this rowkey (excluding it). Step 203: After obtaining one page of data from each table, the data is cached and globally sorted based on the date / time field of each table within the cache. Since the amount of data per page is small, this step takes very little time. Step 204: Retrieve the data that needs to be returned as a response, and delete this data from the cache. The process ends.
[0055] Optionally, the step of querying the target data according to the query request to obtain feedback data specifically includes: The target data is filtered according to the query conditions, and the data that meets the query conditions is determined as the feedback data; After exporting the feedback data, delete the feedback data from the cache.
[0056] In this embodiment, the query conditions are used to filter the target data in the cache. The data left after filtering according to the query conditions is the feedback data. After retrieving the feedback data, the feedback data in the cache needs to be deleted to maintain the space in the cache.
[0057] Optionally, the method further includes: Determine if the next page of data exists in the cache. If the next page of data exists, end the process. If no data is available on the next page, the target table is queried according to the request parameters to obtain the target data.
[0058] In this embodiment, when calling Figure 2 When performing multi-table data queries, an asynchronous thread is started to determine whether the data in the cache satisfies the requirements for the next page query, i.e., whether the data for the next page in the target table exists. If it does, the process ends; otherwise, the multi-table query pagination method is called to retrieve the data and update the cache, so that the next page query can directly retrieve data from the cache. This improves the efficiency of querying the target data during the query process.
[0059] Optionally, the method further includes: If data is cached for a period exceeding a preset expiration time, the data will be deleted.
[0060] In this embodiment, in order to ensure the utilization rate of space in the cache, it is necessary to delete data that has been in the cache for a long time. The expiration time can be customized.
[0061] In one possible implementation, the expiration time is set to 30 minutes to improve query performance.
[0062] Figure 3 This is a flowchart illustrating a multi-table query pagination method according to yet another exemplary embodiment. For example... Figure 3 The method flow is as follows: It receives external requests (i.e., query requests). The external request is carried in XML message format, which contains the service interface ID, request parameters, and globally unique traceId. The request parameters include query conditions, sorting field, page number (page_num), and number of records per page (page_size). The globally unique traceId remains unchanged throughout a query, that is, it will not change when paginating, unless the request parameters change or the query is repeated.
[0063] The XML message is parsed using the service method, and multiple predefined HBase table names to be queried are obtained based on the service interface ID.
[0064] The process checks if the required data for the current page exists in the Redis cache. Data in the cache is identified by its MD5 hash (generated using a globally unique traceId and all request parameters). If the data contains the MD5 hash of the current external request, the corresponding data is retrieved from the cache and encapsulated into an XML response message. This message includes the globally unique traceId from the request message, and the process ends. If the current page data is not in the cache, the HBase multi-table data query method is called to retrieve the data, which is then encapsulated into an XML response message, and the synchronization process ends.
[0065] When calling the HBase multi-table data query method as described above, an asynchronous thread is started to determine whether the data in the cache meets the query requirements for the next page. If it does, the process ends; otherwise, the HBase multi-table data query method is called to retrieve the data for the next page in the target table and the cache is updated, so that the data for the next page can be retrieved directly from the cache.
[0066] Figure 4 This is a block diagram illustrating a multi-table query pagination apparatus according to an exemplary embodiment. (Refer to...) Figure 4 The device 400 includes: The target table determination module 410 is used to obtain a query request and determine the target table based on the query request. The target data determination module 420 is used to determine the target data in the cache that corresponds to the query request; The response module 430 is used to query the target data according to the query request to obtain feedback data, and generate a response message based on the feedback data.
[0067] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0068] Figure 5 This is a block diagram illustrating an apparatus 800 according to an exemplary embodiment. For example, apparatus 800 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0069] Reference Figure 5 The device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0070] Processing component 802 typically controls the overall operation of device 800, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 802 may include one or more processors 820 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 802 may include one or more modules to facilitate interaction between processing component 802 and other components. For example, processing component 802 may include a multimedia module to facilitate interaction between multimedia component 808 and processing component 802.
[0071] Memory 804 is configured to store various types of data to support the operation of device 800. Examples of this data include instructions for any application or method operating on device 800, contact data, phonebook data, messages, pictures, videos, etc. Memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0072] Power supply component 806 provides power to various components of device 800. Power supply component 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to device 800.
[0073] Multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 808 includes a front-facing camera and / or a rear-facing camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0074] Audio component 810 is configured to output and / or input audio signals. For example, audio component 810 includes a microphone (MIC) configured to receive external audio signals when device 800 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 804 or transmitted via communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
[0075] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0076] Sensor assembly 814 includes one or more sensors for providing status assessments of various aspects of device 800. For example, sensor assembly 814 may detect the on / off state of device 800, the relative positioning of components such as the display and keypad of device 800, changes in the position of device 800 or a component of device 800, the presence or absence of user contact with device 800, the orientation or acceleration / deceleration of device 800, and temperature changes of device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 814 may also include an accelerometer, a gyroscope, a magnetometer, a pressure sensor, or a temperature sensor.
[0077] Communication component 816 is configured to facilitate wired or wireless communication between device 800 and other devices. Device 800 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 816 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 816 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0078] In an exemplary embodiment, the apparatus 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0079] In an exemplary embodiment, a storage medium including instructions is also provided, such as a memory 804 including instructions, which can be executed by a processor 820 of the device 800 to perform the above-described method. Optionally, the storage medium may be a non-transitory computer-readable storage medium, such as a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device.
[0080] Figure 6This is a block diagram illustrating an apparatus 900 according to an exemplary embodiment. For example, apparatus 900 may be provided as a server. (Refer to...) Figure 6 The apparatus 900 includes a processing component 922, which further includes one or more processors, and memory resources represented by memory 932 for storing instructions, such as application programs, that can be executed by the processing component 922. The application programs stored in memory 932 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 922 is configured to execute instructions to perform the methods described above.
[0081] Device 900 may also include a power supply component 926 configured to perform power management of device 900, a wired or wireless network interface 950 configured to connect device 900 to a network, and an input / output (I / O) interface 958. Device 900 may operate on an operating system stored in memory 932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.
[0082] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the following claims.
[0083] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A multi-table query pagination method, characterized in that, include: Obtain a query request, determine at least one target table based on the query request, the query request includes a service interface ID, request parameters and a tracking ID, and the query request includes query conditions, sorting fields, number of pages to query and number of records per page; Generate an MD5 value based on the request parameters and the tracking ID, which will serve as the target identifier; If target data carrying the target identifier exists in the cache, then the target data is retrieved; If the target data carrying the target identifier is not found in the cache, all target tables are queried concurrently, and the data of each page of the target table is added to the cache in sequence according to the number of pages queried and the number of records per page; wherein, after each table has queried a page of data, the rowkey of the last record in the current page is recorded and placed in the cache, and when querying the next page, the query starts from the next rowkey adjacent to the rowkey; The target data is generated by globally sorting the data of each target table within the cache according to the sorting field. The target data is filtered according to the query conditions, and the data that meets the query conditions is determined as feedback data; After exporting the feedback data, delete the feedback data from the cache, and generate a response message based on the feedback data; The method further includes: Determine if the next page of data exists in the cache. If the next page of data exists, end the process. If no data is available on the next page, all target tables are queried concurrently. Data from the target tables is added to the cache sequentially according to the page number and the number of records per page. Within the cache, the data in each target table is globally sorted according to the sorting field to generate the target data.
2. The method according to claim 1, characterized in that, The step of determining at least one target table based on the query request specifically includes: The service retrieval method obtains at least one target table name based on the service interface ID, and the table corresponding to the target table name is the target table.
3. The method according to claim 1, characterized in that, The step of adding the data of each page in the target table to the cache sequentially according to the query page number and the number of records per page specifically includes: The page to be queried in each target table is determined based on the number of pages to be queried. Data is selected from the page to be queried based on the number of items per page and added to the cache.
4. The method according to claim 1, characterized in that, The method further includes: If data is cached for a period exceeding a preset expiration time, the data will be deleted.
5. A multi-table query pagination device, characterized in that, The apparatus is used to implement the multi-table query pagination method as described in claim 1, and the apparatus includes: The target table determination module is used to obtain a query request and determine the target table based on the query request. The query request includes a service interface ID, request parameters, and a tracking ID. The query request also includes query conditions, sorting fields, query page number, and number of records per page. The target data determination module is used to determine the target data in the cache that corresponds to the query request; The response module is used to query the target data according to the query request to obtain feedback data, and generate a response message based on the feedback data.
6. An electronic device, characterized in that, include: processor; Memory used to store the processor's executable instructions; The processor is configured to execute the instructions to implement the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method as described in any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the method according to any one of claims 1 to 4.