CN116450669A - Data query method, device, computer equipment and storage medium - Google Patents

Data query method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN116450669A
CN116450669A CN202310439738.7A CN202310439738A CN116450669A CN 116450669 A CN116450669 A CN 116450669A CN 202310439738 A CN202310439738 A CN 202310439738A CN 116450669 A CN116450669 A CN 116450669A
Authority
CN
China
Prior art keywords
sub
data
data query
target
query statement
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310439738.7A
Other languages
Chinese (zh)
Inventor
许心熠
陈勇清
朱琪
王涵韬
黄健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Original Assignee
Industrial Bank Co Ltd
CIB Fintech Services Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial Bank Co Ltd, CIB Fintech Services Shanghai Co Ltd filed Critical Industrial Bank Co Ltd
Priority to CN202310439738.7A priority Critical patent/CN116450669A/en
Publication of CN116450669A publication Critical patent/CN116450669A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2428Query predicate definition using graphical user interfaces, including menus and forms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24554Unary operations; Data partitioning operations
    • G06F16/24556Aggregation; Duplicate elimination
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present application relates to a data query method, apparatus, computer device, storage medium and computer program product. The method comprises the following steps: responding to a query request aiming at a database, acquiring a data query statement, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned; determining the data quantity conforming to the data query statement in each sub-table, and sequencing the data quantity according to the sequence of a plurality of sub-tables; determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data quantity; and acquiring a data query result conforming to the data query statement from the target sub-table. The method can realize screening of the query object, namely the target sub-table, based on the data quantity conforming to the data query statement in each sub-table and the sequence of a plurality of sub-tables within the corresponding quantity range of the data query statement, thereby reducing the number of sub-tables needing to be queried and greatly improving the data query efficiency.

Description

Data query method, device, computer equipment and storage medium
Technical Field
The present application relates to the field of big data technologies, and in particular, to a data query method, apparatus, computer device, storage medium, and computer program product.
Background
Today, the mobile internet is vigorously developed, and various system applications are presented. Each system application needs to have a corresponding data storage function, and the most common function implementation manner is to use a database for data storage. However, with the dramatic increase in the number of users and the amount of user data, database tables have failed to support the storage of such large data, and therefore multiple sub-tables are required for storage. When a query is made against the database in which the sub-tables exist, data that meets the query conditions may exist in any of the sub-tables, and thus, it is necessary to query data across the sub-tables.
In the conventional technology, all data meeting the query conditions can be queried once in each sub-table according to the query conditions, and finally, all the data meeting the query conditions are concentrated to a central node of a database, and the central node sorts all the data meeting the query conditions according to the paging conditions and returns corresponding data meeting the paging condition page numbers. However, in this manner in the conventional technology, since a corresponding query operation needs to be performed on each sub-table in the database to obtain all data meeting the query condition and return the data, the amount of data to be processed is too large, which is easy to cause a problem of low query efficiency.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an efficient data query method, apparatus, computer device, computer-readable storage medium, and computer program product.
In a first aspect, the present application provides a data query method. The method comprises the following steps:
responding to a query request aiming at a database, acquiring a data query statement, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned;
determining the data quantity conforming to the data query statement in each sub-table, and sorting the data quantity according to the sequence of a plurality of sub-tables;
determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data quantity;
and acquiring a data query result conforming to the data query statement from the target sub-table.
In one embodiment, the obtaining the data query result conforming to the data query statement from the target sub-table includes:
generating sub-table query sentences corresponding to each target sub-table according to the target data quantity conforming to the data query sentences in each target sub-table and the data query sentences under the condition that the number of the target sub-tables is a plurality of;
Obtaining sub-table data conforming to the sub-table query statement from each target sub-table;
and generating the data query result according to the sub-table data of each target sub-table.
In one embodiment, the generating the sub-table query statement corresponding to each target sub-table according to the target data volume in each target sub-table and the data query statement, includes:
determining the sub-table quantity range of sub-table data to be returned by each target sub-table according to the target data quantity and the quantity range of each target sub-table;
and generating sub-table query sentences corresponding to each target sub-table by adopting the data query sentences and the sub-table quantity range according to the query rules corresponding to each target sub-table.
In one embodiment, the determining the data amount in each sub-table that conforms to the data query statement includes:
creating a data query thread corresponding to each sub-table;
and acquiring the data quantity conforming to the data query statement from each sub-table by adopting the data query thread corresponding to each sub-table.
In one embodiment, the obtaining the data query result conforming to the data query statement from the target sub-table includes:
and under the condition that the number of the target sub-tables is multiple, respectively adopting the data query threads corresponding to each target sub-table to acquire the data query result conforming to the data query statement from each target sub-table.
In one embodiment, the determining the target sub-table from the plurality of sub-tables according to the number range and the ordered data amount includes:
splicing according to the ordered data quantity to obtain a sub-table number axis;
according to the quantity range, determining a start sub-table and an end sub-table from the sub-table number axis, wherein the start sub-table is the sub-table where the first data needing to be returned is located, and the end sub-table is the sub-table where the last data needing to be returned is located;
and determining the target sub-table according to the initial sub-table and the end sub-table.
In a second aspect, the present application further provides a data query device. The device comprises:
the request response module is used for responding to a query request aiming at a database, acquiring a data query statement, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned;
The sub-table sorting module is used for determining the data quantity conforming to the data query statement in each sub-table and sorting the data quantity according to the sequence of a plurality of sub-tables;
the sub-table screening module is used for determining a target sub-table from a plurality of sub-tables according to the quantity range and the ordered data quantity;
and the data query module is used for acquiring the data query result conforming to the data query statement from the target sub-table.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the data query method according to any embodiment of the first aspect.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the data query method according to any one of the embodiments of the first aspect.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which is executed by a processor to implement the data query method according to any embodiment of the first aspect.
The data query method, the data query device, the computer equipment, the storage medium and the computer program product acquire a data query statement by responding to a query request aiming at a database, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned; determining the data quantity conforming to the data query statement in each sub-table, and sequencing the data quantity according to the sequence of a plurality of sub-tables; determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data quantity; the data query result conforming to the data query statement is obtained from the target sub-table, and the screening of the query object, namely the target sub-table, can be realized based on the data quantity conforming to the data query statement in each sub-table and the sequence of a plurality of sub-tables within the corresponding quantity range of the data query statement, so that the number of sub-tables needing to be queried is reduced, and the data query efficiency is greatly improved. Meanwhile, as only the data query result conforming to the data query statement in the target sub-table is required to be obtained, the data quantity returned after query can be reduced, and therefore the storage resources occupied by the computer equipment when executing the data query operation are reduced.
Drawings
FIG. 1 is an application environment diagram of a data polling method in one embodiment;
FIG. 2 is a flow diagram of a method of data polling in one embodiment;
FIG. 3 is a flow chart of the data query result generation step in one embodiment;
FIG. 4 is a flow chart of the target sub-table determination step in one embodiment;
FIG. 5 is a schematic diagram of the fractional axes in one embodiment;
FIG. 6 is a flow chart of a data polling method in another embodiment;
FIG. 7 is a block diagram of the structure of a data polling device in one embodiment;
fig. 8 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
It should be noted that, user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
The data query method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may utilize a database to store data that needs to be processed by the server 104, and the database may include a plurality of sub-tables (those skilled in the art will appreciate that the sub-tables in the embodiments of the present application are tables storing data satisfying the data query statement). The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. Specifically, the server 104 may respond to the data query request sent by the terminal 102 for the database, and parse the data query request to obtain a data query statement, where the data query statement may carry a range of data amounts that need to be returned. The server 104 may determine, according to the query condition in the data query statement and the data stored in each sub-table, the data amount in each sub-table of the database, where the data amount corresponds to the data query statement, and sort the data amounts corresponding to each sub-table according to the order of the plurality of sub-tables. The server 104 may determine a target sub-table to be queried from multiple sub-tables of the database according to the number range carried by the data query statement and the data amount corresponding to each sub-table after sequencing, and obtain a data query result conforming to the data query statement from the target sub-table. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart car devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, a data query method is provided, and the method is applied to the server 104 in fig. 1 for illustration, and includes the following steps:
step S202, responding to a query request for a database, and acquiring a data query statement.
Wherein the database may include a plurality of sub-tables. Several pieces of data may be stored in each sub-table. Alternatively, in some embodiments, the data storage amount of each sub-table may be set to be the same.
The data query statement may carry a range of amounts of data that need to be returned. In one example, the number of data query statements carried may range from a specific threshold, such as two thousand pieces of data; alternatively, a threshold interval, such as the first thousand pieces of data to the first thousand hundred pieces of data, may be used.
Specifically, the server may parse the query request to obtain a data query statement in response to the query request for the database sent by the terminal. The query request for the database may be generated by the terminal according to a query instruction input by a user, or may be generated by the terminal automatically according to a page number of a page to be rendered and a data display rule corresponding to the page when detecting that the page jumps.
Step S204, determining the data quantity conforming to the data query statement in each sub-table, and sorting the data quantity according to the sequence of the plurality of sub-tables.
Specifically, the server may determine the data stored in each sub-table according to the query condition in the data query statement, and execute the accumulation operation on the data amount conforming to the data query statement in the sub-table when determining that the currently determined data satisfies the query condition, until all the data in each sub-table is traversed, and then determine the data amount conforming to the data query statement in each sub-table.
The server may sort the data amounts in each sub-table according to the orders of the plurality of sub-tables, so as to obtain the data amount corresponding to each sub-table after sorting. Wherein the order of the plurality of sub-tables may be user-preconfigured; alternatively, it may be determined according to the primary key field carried by the data stored in each sub-table, for example, in the case of taking id (Identity document, unique code) as the primary key field, if the id range corresponding to the data stored in sub-table 1 is [1,1000], and the id range corresponding to the data stored in sub-table 2 is [1001,2000], it may be determined that the order of sub-table 1 precedes sub-table 2; alternatively, in the case of taking the data name initials as the primary key field, if the data name initials stored in the sub-table 3 are a-B and the data name initials stored in the sub-table 4 are X-Z, it may be determined that the order of the sub-table 3 precedes the sub-table 4.
Step S206, determining a target sub-table from the plurality of sub-tables according to the number range and the ordered data quantity.
Specifically, the server may sequentially accumulate the data amounts corresponding to each sorted sub-table until the accumulated data amounts meet the number range carried by the data query statement. And determining a target sub-table to be queried from a plurality of sub-tables of the database according to the sub-table corresponding to the current accumulated data quantity.
Step S208, obtaining the data query result conforming to the data query statement from the target sub-table.
Specifically, the server may determine the data stored in the target sub-table according to the query condition in the data query statement, and execute the reading operation on the currently determined data when determining that the currently determined data meets the query condition, so as to obtain the data query result in the target sub-table, which accords with the data query statement.
In the data query method, a data query statement is obtained by responding to a query request aiming at a database, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned; determining the data quantity conforming to the data query statement in each sub-table, and sequencing the data quantity according to the sequence of a plurality of sub-tables; determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data quantity; the data query result conforming to the data query statement is obtained from the target sub-table, and the screening of the query object, namely the target sub-table, can be realized based on the data quantity conforming to the data query statement in each sub-table and the sequence of a plurality of sub-tables within the corresponding quantity range of the data query statement, so that the number of sub-tables needing to be queried is reduced, and the data query efficiency is greatly improved. Meanwhile, as only the data query result conforming to the data query statement in the target sub-table is required to be obtained, the data quantity returned after query can be reduced, and therefore the storage resources occupied by the computer equipment when executing the data query operation are reduced.
In one embodiment, in the case that the number of the target sub-tables is plural, as shown in fig. 3, step S208, obtaining the data query result conforming to the data query statement from the target sub-table includes:
step S302, generating a sub-table query statement corresponding to each target sub-table according to the target data volume conforming to the data query statement in each target sub-table and the data query statement.
Specifically, after the server determines the query object, i.e., the target sub-table, the query logic for the database may be logically split into sub-table query logic for each target sub-table. And generating a sub-table query statement corresponding to each target sub-table by adopting the target data quantity, the data storage address and the data query statement of each target sub-table, which are in accordance with the data query statement, in each target sub-table.
Optionally, in some embodiments, the server may update the number range carried by the data query statement and the data query range according to the target data amount and the data storage address corresponding to each target sub-table, so as to obtain the sub-table query statement corresponding to each target sub-table. For example, in the case where the target data amount in the target sub-table is 200 and the data storage address is Tab [1] and the number of carried data query sentences is 2000 and the data query ranges are Tab [1,10], a sub-table query sentence with the number of carried data ranging from 200 and the data query range being Tab [1] corresponding to the target sub-table can be generated. In addition, the table query statement generation method provided in the embodiment may also be applicable to a scenario in which the number of target tables is one.
Or, the server may sequentially accumulate the target data amounts corresponding to each target sub-table according to the order of the plurality of target sub-tables until the accumulated value of the target data amounts meets the number range carried by the data query statement, thereby determining the number of returned data corresponding to each target sub-table. And updating the data query statement by adopting the quantity of returned data and the data storage address corresponding to each target sub-table, thereby generating the sub-table query statement corresponding to each target sub-table.
Step S304, sub-table data conforming to the sub-table query statement is obtained from each target sub-table.
Specifically, the server may perform a data query operation on each target sub-table using the sub-table query statement corresponding to each target sub-table, and obtain sub-table data conforming to the sub-table query statement from each target sub-table. For example, the server may determine the data stored in each target sub-table by using the query condition in the sub-table query statement, and when determining that the currently determined data meets the query condition, take the currently determined data as sub-table data in the target sub-table, which meets the sub-table query statement, and read the sub-table data.
Step S306, according to the sub-table data of each target sub-table, generating a data query result which accords with the data query statement in the database.
Specifically, the server may splice the sub-table data meeting the sub-table query condition in each target sub-table in sequence according to the sequence of each target sub-table, so as to obtain the data query result meeting the data query statement in the database. Or, the server may combine the sub-table data meeting the sub-table query condition in each target sub-table according to the form of the table to generate a data query result meeting the data query statement in the database.
In this embodiment, when the number of the target sub-tables is multiple, according to the target data amount and the data query statement in each target sub-table, the sub-table query statement corresponding to each target sub-table is generated, the sub-table data in accordance with the sub-table query statement is obtained from each target sub-table, and the data query result in accordance with the data query statement is generated according to the sub-table data of each target sub-table, so that the query logic split for the database can be realized on the software logic level, thereby simplifying the data query operation for the target sub-table, and improving the data query efficiency for the target sub-table.
In one embodiment, step S302, generating a sub-table query statement corresponding to each target sub-table according to the target data amount in each target sub-table and the data query statement, includes: according to the target data quantity and quantity range of each target sub-table, determining the sub-table quantity range of the sub-table data required to be returned by each target sub-table, and generating sub-table query sentences corresponding to each target sub-table by adopting data query sentences and sub-table quantity ranges according to the query rules corresponding to each target sub-table.
Wherein the definition of the number range of the sub-table can refer to the definition of the number range in the above embodiment.
Specifically, the server may sequentially accumulate the target data amounts corresponding to each target sub-table according to the order of the plurality of target sub-tables, and match the accumulated value of the target data amounts obtained after each accumulation with the number range carried by the data query statement until the accumulated value of the target data amounts meets the number range carried by the data query statement. Stopping accumulation and acquiring the accumulation amount corresponding to each target sub-table at the moment. And determining the sub-table quantity range of the sub-table data to be returned by each target sub-table according to the accumulation amount corresponding to each target sub-table.
The server may store a query rule corresponding to each sub-table in advance. And determining the query rule corresponding to each target sub-table from the query rules according to the identification of each target sub-table. And constraining the data query statement and the sub-table quantity range corresponding to each target sub-table according to the query rule of each target sub-table, thereby generating the sub-table query statement corresponding to each target sub-table. The query rule may be used to constrain any one or more of parameters such as data query address, data query scope, data query format, and the like.
In one example, the number of data query sentences carried in the data query sentences is 2000, the target data volume conforming to the data query sentences in the target sub-table 1 is 200, the target data volume conforming to the data query sentences in the target sub-table 2 is 1000, the target data volume conforming to the data query sentences in the target sub-table 3 is 1000, and the sequence among the target sub-tables is: in the case of the target sub-table 1, the target sub-table 2, and the target sub-table 3, the server may first accumulate the target data amounts corresponding to the target sub-table 1 and the target sub-table 2, and match the value obtained by the accumulation with the number range. And under the condition of determining that the matching fails, accumulating the target data quantity of the target sub-table 3 until the quantity range 2000 is met. At this time, the accumulation amount corresponding to the target table 1 is 200, the accumulation amount corresponding to the target table 2 is 1000, and the accumulation amount corresponding to the target table 3 is 800.
In another example, in the case where 1000 pieces of data are stored in each target sub-table, a query rule corresponding to the target sub-table 1 may be stored in advance in the server: the data query range is id [1,1000]; the query rules corresponding to the target sub-table 2 are: the data query range is id [1001,2000]; the query rules corresponding to target sub-table 3 are: the data query range is id 2001,3000. Where id corresponds to each piece of data.
When the data query statement is "id >800, limit2000 (i.e., the range of the number of data to be returned is 2000)", and the target data amount of the target sub-table 1 is 200, the target data amount of the target sub-table 2 is 1000, and the target data amount of the target sub-table 3 is 1000, the sub-table query range and the data query statement are constrained according to the query rule corresponding to the target sub-table, so that the sub-table query statement corresponding to the target sub-table 1 is "id >800, limit200"; the sub-table query statement corresponding to the target sub-table 2 is "id >1000, limit1000"; the sub-table query statement corresponding to the target sub-table 3 is "id >2000.Limit800".
In this embodiment, the sub-table number range of the sub-table data to be returned by each target sub-table is determined according to the target data amount and the number range carried by the data query statement in each target sub-table, and the sub-table query statement is generated by adopting the data query statement and the sub-table number range according to the query rule corresponding to each target sub-table, so that the generation accuracy of the sub-table query statement can be improved. Meanwhile, the sub-table query statement is generated by adopting the sub-table number range of the sub-table data which needs to be returned by each target sub-table, so that the query operation on the current target sub-table can be directly ended after the sub-table data which accords with the sub-table number range is acquired, and all the data in the current target sub-table do not need to be traversed, thereby being convenient for effectively reducing the data query amount and improving the query efficiency on the target sub-table.
In one embodiment, step S204, determining the data amount in each sub-table that conforms to the data query statement, and ordering the data amounts in the order of the plurality of sub-tables includes: creating a data query thread corresponding to each sub-table, and acquiring the data quantity conforming to the data query statement from each sub-table by adopting the data query thread corresponding to each sub-table.
Specifically, after retrieving the data query statement, the server may create a data query thread corresponding to each sub-table in the database. And synchronously acquiring the data quantity conforming to the data query statement from each sub-table by adopting the data query thread corresponding to each sub-table in a multi-thread concurrence mode. The specific data amount acquiring operation may be implemented with reference to the data amount acquiring manner provided in the above embodiment, which is not specifically described herein.
In this embodiment, by creating a data query thread corresponding to each sub-table, and using the data query thread corresponding to each sub-table to obtain the data volume conforming to the data query statement from each sub-table, the efficiency of obtaining the data volume can be greatly improved by using multiple threads.
In one embodiment, step S206, determining the target sub-table from the plurality of sub-tables according to the number range and the ordered data amount, includes: and under the condition that the number of the target sub-tables is multiple, respectively adopting the data query threads corresponding to each target sub-table to acquire the data query results conforming to the data query statement from each target sub-table.
Specifically, in the case that the number of the target sub-tables is multiple, the server may execute a corresponding data query operation according to the data query statement for the database by using the data query thread corresponding to each target sub-table, so as to query from each target sub-table to obtain a data query result conforming to the data query statement in the database.
Optionally, in some embodiments, a number threshold corresponding to the target sub-table number may also be preconfigured in the server. When the number of the target sub-tables is multiple and the number threshold is not exceeded, a single data query thread can be adopted to sequentially query the data of each target sub-table, so that interaction between the server and the threads is reduced. When the number of the target sub-tables is multiple and the number threshold is exceeded, the data query thread corresponding to each target sub-table can be adopted to perform the data query operation, so that the data query efficiency of the target sub-tables is improved.
In this embodiment, by acquiring data conforming to the data query statement from each target sub-table by using the data query thread corresponding to each target sub-table, the data query operation on the plurality of target sub-tables can be executed in parallel, thereby improving the data query efficiency.
In one embodiment, as shown in fig. 4, step S206, determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data amount, includes:
and step S402, splicing according to the ordered data quantity to obtain a fractional number axis.
Wherein, the branch table number axis can be used for representing the number axis formed by mapping the data conforming to the data query statement in each branch table into points and connecting the points into lines according to the sequence of each branch table. That is, each point on the branch table number axis corresponds to data in each branch table that corresponds to a data query statement, respectively.
Specifically, the server may map the data conforming to the data query statement in each sub-table to the point corresponding to each sub-table according to the data volume conforming to the data query statement in each sub-table after sorting, and splice the points corresponding to each sub-table in turn, thereby forming the sub-table number axes corresponding to the plurality of sub-tables.
Step S404, determining a start sub-table and an end sub-table from the sub-table number axis according to the number range.
The initial sub-table may be used to characterize the sub-table in which the first data to be returned corresponding to the data query statement is located. The last sub-table can be used for representing the sub-table where the last data to be returned corresponding to the data query statement is located.
Step S406, determining a target sub-table according to the initial sub-table and the end sub-table.
Specifically, the server may convert the number range carried by the data query statement into a section corresponding to the branch table number axis according to the mapping relationship between the data amount of the branch table and the branch table number axis. And determining the sub-table in which the first data to be returned is located and the sub-table in which the last data to be returned is located from the sub-table number axis by utilizing the interval, namely, a start sub-table and an end sub-table corresponding to the number range carried by the data query condition. And determining a target sub-table according to the sequence of the sub-tables and the determined start sub-table and end sub-table.
In one example, as shown in fig. 5, a schematic diagram of a fractional table number axis is provided, where the data amount meeting the data query condition in the fractional table 1 is 200, and all points on the fractional table number axis located in the [1,200] interval have a mapping relationship with the fractional table 1. And if the data quantity meeting the data query condition in the sub-table 2 is 1000, the points on the sub-table number axis, which are positioned in the [201,1200] interval, have a mapping relation with the sub-table 2. If the data amount meeting the data query condition in the sub-table 3 is 1000, the mapping relationship exists between the point located in the [1201,2200] interval on the sub-table number axis and the sub-table 3.
In the case where the number range corresponding to the data query condition is 2000, the server may convert to a section corresponding to the number range [1,2000]. The first data mapping to be returned can be determined to be in the range of the sub-table 1 from the sub-table number axis by adopting the interval corresponding to the number range, and the last data mapping to be returned is determined to be in the range of the sub-table 3. That is, the initial sub-table at this time is sub-table 1, and the final sub-table is sub-table 3. The target table determined from the start table and the end table includes { table 1, table 2, table 3}.
In this embodiment, the sorted data amounts satisfying the data query condition in each sub-table are spliced to obtain the sub-table number axis, and the number range carried by the sub-table number axis and the data query statement is used to determine the start sub-table and the end sub-table, so as to determine the target sub-table, and improve the determination efficiency of the target sub-table.
In one embodiment, as shown in fig. 6, a flow chart of a data query method is provided, including:
step S602, in response to a query request for a database, a data query statement is acquired.
Specifically, the server may parse the query request to obtain a data query statement in response to the query request for the database. And determining a plurality of sub-tables to be processed in the current database according to the data query statement. A data query thread is created corresponding to each sub-table.
Step S604, the data amount conforming to the data query statement is obtained from each sub-table by adopting the data query thread corresponding to each sub-table, and the data amounts are ordered according to the sequence of the plurality of sub-tables.
Specifically, the server may acquire the data amount conforming to the data query statement from each sub-table by using the data query thread corresponding to each sub-table, and sort the data amounts conforming to the data query statement in each sub-table according to the order of the plurality of sub-tables, so as to obtain a plurality of sorted data amounts.
In one example, in the case where there is no order in the existing sub-table in the database, the main key field corresponding to each piece of data may be created by sorting according to the recording time corresponding to the data stored in the sub-table. Thereby determining the order corresponding to each sub-table using the key value of the primary key field.
Step S606, splicing according to the ordered data quantity to obtain a branch table number axis, and determining a target branch table from the branch table number axis according to the quantity range carried by the data query statement.
Specifically, the server may map the data in each sub-table that conforms to the data query statement to a point on the sub-table number axis according to the ordered amount of data. And converting the quantity range carried by the data query statement into a section corresponding to the fractional table number axis, and determining a start fractional table and an end fractional table from the fractional table number axis by utilizing the section corresponding to the quantity range, thereby obtaining the target fractional table.
Step S608, determining the sub-table quantity range of the sub-table data to be returned by each target sub-table according to the target data quantity and quantity range of each target sub-table.
Step S610, according to the query rule corresponding to each target sub-table, the data query statement and the sub-table number range are adopted to generate the sub-table query statement corresponding to each target sub-table.
Step S612, respectively adopting the data query threads corresponding to each target sub-table, obtaining sub-table data conforming to the sub-table query statement from each target sub-table, and generating a data query result conforming to the data query statement in the database according to the sub-table data.
Specifically, the server may sequentially accumulate the target data amounts, which conform to the data query statement, in each target sub-table according to the order of the plurality of target sub-tables until the accumulated values satisfy the number range, and acquire the accumulated value corresponding to each target sub-table at this time, so as to determine the sub-table number range of the sub-table data that needs to be returned by each target sub-table. And constraining the data query statement and the number range of the sub-tables according to the query rule corresponding to each target sub-table, so as to generate the sub-table query statement corresponding to each target sub-table. And respectively adopting a data query thread corresponding to each target sub-table, acquiring sub-table data conforming to the sub-table query statement from each target sub-table, and generating a data query result conforming to the data query statement in the database according to the sub-table data.
In this embodiment, the data amount according with the data query statement in each sub-table is determined by using the data query thread corresponding to each sub-table, the data according with the data query statement in each sub-table is mapped to the sub-table number axis according to the sorted data amounts, and then the target sub-table is screened out by using the number range and the sub-table number axis corresponding to the data query statement, the sub-table number range of the sub-table data required to be returned by each target sub-table is determined, the sub-table query statement corresponding to each target sub-table is generated by using the sub-table data flow range, and the sub-table data according with the sub-table query statement is acquired from each target sub-table by using the data query thread corresponding to each target sub-table, so that the data query result according with the data query statement in the database is obtained, the data query amount can be reduced, the data query logic is simplified, and the data query efficiency is greatly improved.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a data query device for realizing the above related data query method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of one or more data query devices provided below may refer to the limitation of the data query method hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 7, there is provided a data query apparatus 700 comprising: a request response module 702, a sub-table ordering module 704, a sub-table screening module 706, and a data query module 708, wherein:
the request response module 702 is configured to obtain, in response to a query request for a database, a data query statement, where the database includes a plurality of sub-tables, and the data query statement carries a range of amounts of data that needs to be returned.
The sub-table sorting module 704 is configured to determine the data amount in each sub-table, where the data amount conforms to the data query statement, and sort the data amounts according to the order of the plurality of sub-tables.
The sub-table screening module 706 is configured to determine a target sub-table from the multiple sub-tables according to the number range and the ordered data amount.
The data query module 708 is configured to obtain a data query result that conforms to the data query statement from the target sub-table.
In one embodiment, the data query module 708 includes: the statement generating unit is used for generating a sub-table query statement corresponding to each target sub-table according to the target data quantity which accords with the data query statement in each target sub-table and the data query statement under the condition that the number of the target sub-tables is a plurality of; the sub-table acquisition unit is used for acquiring sub-table data conforming to the sub-table query statement from each target sub-table; and the data generating unit is used for generating a data query result according to the sub-table data of each target sub-table.
In an embodiment, the sentence generating unit is further configured to: according to the target data quantity and quantity range of each target sub-table, determining the sub-table quantity range of the sub-table data required to be returned by each target sub-table, and generating sub-table query sentences corresponding to each target sub-table by adopting data query sentences and sub-table quantity ranges according to the query rules corresponding to each target sub-table.
In one embodiment, the sub-table ordering module 704 further includes: the thread creating unit is used for creating a data query thread corresponding to each sub-table, and the thread query unit is used for acquiring the data quantity conforming to the data query statement from each sub-table by adopting the data query thread corresponding to each sub-table.
In one embodiment, the data query module 708 is further configured to, when the number of target sub-tables is multiple, obtain, from each target sub-table, a data query result that conforms to the data query statement, using the data query thread corresponding to each target sub-table.
In one embodiment, the sub-table screening module 706 further comprises: the number axis mapping unit is used for splicing according to the ordered data quantity to obtain a sub-table number axis; the sub-table determining unit is used for determining a start sub-table and an end sub-table from the sub-table number axis according to the number range, determining a target sub-table according to the start sub-table and the end sub-table, wherein the start sub-table is the sub-table where the first data needing to be returned is located, and the end sub-table is the sub-table where the last data needing to be returned is located.
The various modules in the data querying device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 8. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing a plurality of sub-tables. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a data query method.
It will be appreciated by those skilled in the art that the structure shown in fig. 8 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that variations and modifications can be made by those skilled in the art without departing from the spirit of the present application, which falls within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A method of querying data, the method comprising:
responding to a query request aiming at a database, acquiring a data query statement, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned;
determining the data quantity conforming to the data query statement in each sub-table, and sorting the data quantity according to the sequence of a plurality of sub-tables;
Determining a target sub-table from a plurality of sub-tables according to the number range and the ordered data quantity;
and acquiring a data query result conforming to the data query statement from the target sub-table.
2. The method of claim 1, wherein the obtaining the data query result from the target sub-table that matches the data query statement comprises:
generating sub-table query sentences corresponding to each target sub-table according to the target data quantity conforming to the data query sentences in each target sub-table and the data query sentences under the condition that the number of the target sub-tables is a plurality of;
obtaining sub-table data conforming to the sub-table query statement from each target sub-table;
and generating the data query result according to the sub-table data of each target sub-table.
3. The method of claim 2, wherein generating a sub-table query statement corresponding to each of the target sub-tables based on the target data volume in each of the target sub-tables that corresponds to the data query statement and the data query statement comprises:
determining the sub-table quantity range of sub-table data to be returned by each target sub-table according to the target data quantity and the quantity range of each target sub-table;
And generating sub-table query sentences corresponding to each target sub-table by adopting the data query sentences and the sub-table quantity range according to the query rules corresponding to each target sub-table.
4. The method of claim 1, wherein said determining the amount of data in each of said sub-tables that corresponds to said data query statement comprises:
creating a data query thread corresponding to each sub-table;
and acquiring the data quantity conforming to the data query statement from each sub-table by adopting the data query thread corresponding to each sub-table.
5. The method of claim 4, wherein the obtaining the data query result from the target sub-table that matches the data query statement comprises:
and under the condition that the number of the target sub-tables is multiple, respectively adopting the data query threads corresponding to each target sub-table to acquire the data query result conforming to the data query statement from each target sub-table.
6. The method of claim 1, wherein said determining a target sub-table from a plurality of said sub-tables based on said range of numbers and said ordered amount of data comprises:
Splicing according to the ordered data quantity to obtain a sub-table number axis;
according to the quantity range, determining a start sub-table and an end sub-table from the sub-table number axis, wherein the start sub-table is the sub-table where the first data needing to be returned is located, and the end sub-table is the sub-table where the last data needing to be returned is located;
and determining the target sub-table according to the initial sub-table and the end sub-table.
7. A data querying device, the device comprising:
the request response module is used for responding to a query request aiming at a database, acquiring a data query statement, wherein the database comprises a plurality of sub-tables, and the data query statement carries the range of the quantity of data to be returned;
the sub-table sorting module is used for determining the data quantity conforming to the data query statement in each sub-table and sorting the data quantity according to the sequence of a plurality of sub-tables;
the sub-table screening module is used for determining a target sub-table from a plurality of sub-tables according to the quantity range and the ordered data quantity;
and the data query module is used for acquiring the data query result conforming to the data query statement from the target sub-table.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202310439738.7A 2023-04-23 2023-04-23 Data query method, device, computer equipment and storage medium Pending CN116450669A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310439738.7A CN116450669A (en) 2023-04-23 2023-04-23 Data query method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310439738.7A CN116450669A (en) 2023-04-23 2023-04-23 Data query method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116450669A true CN116450669A (en) 2023-07-18

Family

ID=87131824

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310439738.7A Pending CN116450669A (en) 2023-04-23 2023-04-23 Data query method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116450669A (en)

Similar Documents

Publication Publication Date Title
CN113760839A (en) Log data compression processing method and device, electronic equipment and storage medium
CN109697234B (en) Multi-attribute information query method, device, server and medium for entity
CN111008198A (en) Service data acquisition method and device, storage medium and electronic equipment
CN116955856A (en) Information display method, device, electronic equipment and storage medium
CN109063215B (en) Data retrieval method and device
CN111125216A (en) Method and device for importing data into Phoenix
CN115809311A (en) Data processing method and device of knowledge graph and computer equipment
CN116450669A (en) Data query method, device, computer equipment and storage medium
CN114780648A (en) Task scheduling method, device, computer equipment, storage medium and program product
CN114238334A (en) Heterogeneous data encoding method and device, heterogeneous data decoding method and device, computer equipment and storage medium
CN112214494B (en) Retrieval method and device
CN111309704B (en) Database operation method and database operation system
CN111259003B (en) Database establishment method and device
CN117688140B (en) Document query method, device, computer equipment and storage medium
CN116932779B (en) Knowledge graph data processing method and device
CN118035423A (en) Information query method, device, computer equipment and storage medium
CN117236298A (en) Report data generation method, report data generation device, computer equipment, report data generation medium and program product
CN117370339A (en) Report blood edge relationship processing method and device, computer equipment and storage medium
CN113987322A (en) Index data query method and device, computer equipment and computer program product
CN117609303A (en) Multi-table joint query method, device, equipment and storage medium
CN117094292A (en) Form file processing method, form file processing device, form file processing equipment, storage medium and program product
CN116069991A (en) Server data acquisition method, device, computer equipment and storage medium
CN113961636A (en) Object relation query method and device, computer equipment and storage medium
CN116483696A (en) Test case generation method, device, computer equipment and storage medium
CN116028448A (en) Identification code determining method, device, equipment and storage medium of electronic file

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination