Data query method and device, server, medium and product
By applying for permissions and searching the data range, a query statement template is constructed, which solves the problem of complexity of querying hot data and cold data in the same data table, and realizes a simple and efficient data query process.
Patent Information
- Application Number
- CN202410898497.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-08
AI Technical Summary
When the same data table contains both hot data and cold data, the operation of querying records is cumbersome because it is necessary to know in which database the records to be queried are stored, which complicates the query process.
Obtain the query interface ID and data range by applying for permissions, find the target data table and database identifier, and build a query statement template to simplify the query process. Users do not need to know the specific database where the records are stored.
Data query operations are simplified. Users only need to enter query information to obtain results without knowing the specific database where the records are stored, which improves query efficiency and convenience.
Smart Images

Figure CN118747189A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data query, and more specifically, to a data query method, device, server, medium and product. Background Art
[0002] In the related art, the records contained in the data table can be divided into different levels of data according to the query frequency. For example, the records contained in the data table can be divided into hot data and cold data in descending order according to the query frequency. The database storing hot data is different from the database storing cold data. The same data table may include both hot data and cold data.
[0003] If the same data table includes both hot data and cold data, then different records in the same data table are stored in different databases. When querying the records in the data table, it is necessary to know in which database the records to be queried are stored, which makes the operation of querying the records in the data table cumbersome. Summary of the invention
[0004] In view of this, the present application provides a data query method, device, server, medium and product.
[0005] To achieve the above objectives, this application provides the following technical solutions:
[0006] According to a first aspect of an embodiment of the present disclosure, a data query method is provided, including:
[0007] Acquire query information, the query information including a target query interface ID and query conditions, the query conditions including a query time range, and the target query interface ID refers to an ID corresponding to a data range with query authority;
[0008] From the preset correspondence between the query interface ID, the data table name and the data range, searching for the target data table name and the target data range corresponding to the target query interface ID; the data range corresponding to the data table name includes a sub-time interval of a time interval consisting of one or more fields in the data table having the data table name and the field value of the time field;
[0009] The target query interface ID is allocated after the permission request is approved, and the permission request includes the target data table name and the target data range corresponding to the target data table name;
[0010] If the query condition belongs to the target data range, searching for the target data table name and the target database identifier corresponding to the query time range from the preset correspondence between the data table name, time range and database identifier;
[0011] Searching for a target query statement template corresponding to the target database identifier from a preset correspondence relationship between the database identifier and the query statement template;
[0012] Fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement;
[0013] The query result is obtained from the database having the target database identifier through the query statement.
[0014] According to a second aspect of an embodiment of the present disclosure, a data query device is provided, including:
[0015] A first acquisition module is used to acquire query information, wherein the query information includes a target query interface ID and a query condition, wherein the query condition includes a query time range, and the target query interface ID refers to an ID corresponding to a data range with query authority;
[0016] A first search module is used to search for a target data table name and a target data range corresponding to the target query interface ID from a preset correspondence relationship between the query interface ID, the data table name and the data range; the data range corresponding to the data table name includes a sub-time interval of a time interval consisting of one or more fields in a data table having the data table name and a field value of a time field;
[0017] The target query interface ID is allocated after the permission request is approved, and the permission request includes the target data table name and the target data range corresponding to the target data table name;
[0018] A second search module is used to search for the target data table name and the target database identifier corresponding to the query time range from the preset correspondence relationship between the data table name, time range and database identifier if the query condition belongs to the target data range;
[0019] A third search module, used to search for a target query statement template corresponding to the target database identifier from a preset correspondence relationship between the database identifier and the query statement template;
[0020] A second acquisition module, used to fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement;
[0021] The third acquisition module is used to acquire the query result from the database having the target database identifier through the query statement.
[0022] According to a third aspect of an embodiment of the present disclosure, a server is provided, comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method described in the first aspect.
[0023] According to a fourth aspect of an embodiment of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0024] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, comprising a computer program, which implements the steps of the method described in the first aspect when executed by a processor.
[0025] Through the above technical solution, it can be known that this application provides a data query method. Before querying data, it is necessary to apply for a data range, that is, to apply for records that users can query by applying for permission. The permission request includes the data table name and the data range corresponding to the data table name. If the permission request is approved, the corresponding relationship between the query interface ID, the data table name and the data range can be constructed. If the user needs to query data, he can enter the query information, which includes the target query interface ID and the query conditions, and the query conditions include the query time range; from the preset query interface ID, the corresponding relationship between the data table name and the data range, find the target data table name and the target data range corresponding to the target query interface ID; if the query condition belongs to the target data range, it means that within the user's query authority, since different records in the same data table may be stored in different databases, it is necessary to find the target data table name and the target database identifier corresponding to the query time range from the preset data table name, the corresponding relationship between the time range and the database identifier; thereby determining which databases need to be used to obtain the query results; from the preset database identifier and the corresponding relationship between the query statement template, find the target query statement template corresponding to the target database identifier; fill the target data table name and the query conditions into the corresponding position of the target query statement template to obtain the query statement; obtain the query results from the database with the target database identifier through the query statement. In this application, when querying records, the user only needs to enter the query information, without having to know which databases the records to be queried belong to, and without having to construct a query statement for each database, thereby making the query operation simple. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0027] Figure 1 is a schematic diagram of a hardware architecture involved in the present application according to an exemplary embodiment;
[0028] Figure 2 is a flow chart of a data query method according to an exemplary embodiment;
[0029] Figure 3 is a block diagram of a data query device according to an exemplary embodiment;
[0030] Figure 4 The invention is a block diagram showing a device for a server according to an exemplary embodiment. DETAILED DESCRIPTION
[0031] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0032] The embodiments of the present application provide a data query method, device, server, medium and product. Before introducing the embodiments of the present application, the hardware architecture involved in the present application is first described.
[0033] Figure 1 It is a schematic diagram of a hardware architecture involved in the present application according to an exemplary embodiment, and the hardware architecture includes but is not limited to: an electronic device 11, a server 12 and multiple databases 13.
[0034] Exemplarily, the electronic device 11 can be any electronic product that can interact with a user through one or more methods such as a keyboard, touchpad, touch screen, remote control, voice interaction or handwriting device, such as a mobile phone, tablet computer, PDA, personal computer, wearable device, etc.
[0035] Exemplarily, the user may input query information through a user interface displayed by the electronic device 11 .
[0036] Exemplarily, the server 12 may be a single server, or a server cluster consisting of multiple servers, or a cloud computing service center.
[0037] For example, the server 12 can respond to the query information and can determine in which database the record corresponding to the query information is stored, so that the query result can be obtained from the corresponding database.
[0038] In the embodiment of the present application, a piece of information stored in the data table is referred to as a record. For example, each row in the data table is a record.
[0039] Exemplarily, records can be divided into hot data, warm data, cold data, and worthless data according to query frequency from high to low; the databases 13 storing hot data, warm data, cold data, and worthless data are different. For example, a database storing hot data is called a hot database, a database storing warm data is called a warm database, a database storing cold data is called a cold database, and a database storing worthless data is called a worthless database.
[0040] Exemplarily, if the query frequency of a record is higher than or equal to a first threshold, the record is determined to be hot data; if the query frequency of a record is less than the first threshold and greater than or equal to a second threshold, the record is determined to be warm data; if the query frequency of a record is less than the second threshold and greater than or equal to a third threshold, the record is determined to be cold data; if the query frequency of a record is less than the third threshold, the record is determined to be worthless data.
[0041] Among them, the first threshold>the second threshold>the third threshold.
[0042] It is understandable that a suitable database is selected to store the corresponding records. For example, hot data can be stored in a HIVE database on a Hadoop cluster. The HIVE database is characterized by high query performance, but high cost and small capacity. Exemplarily, warm data is stored in another HIVE database, but some technical means such as selecting a compression algorithm with a high compression ratio and reducing the number of data copies can be used to reduce the storage space occupied by warm data and expand the upper limit of data storage time of a single cluster; cold data can be stored in an object storage or disk, which has a larger capacity and lower cost, but is not convenient for record query.
[0043] In summary, the database 13 may include a HIVE database and a disk.
[0044] Those skilled in the art should understand that the above-mentioned devices are only examples, and other existing or future devices that are applicable to the present disclosure should also be included in the scope of protection of the present disclosure and are included here by reference.
[0045] The data query method provided in the embodiment of the present application is described below in conjunction with the above hardware architecture.
[0046] Figure 2 is a flow chart of a data query method according to an exemplary embodiment. Figure 2 As shown, the data querying method is used in the server 12, and includes the following steps S201 to S206.
[0047] Step S201: Acquire query information, the query information including a target query interface ID and query conditions, the query conditions including a query time range.
[0048] The target query interface ID refers to the ID corresponding to the data range with query permission.
[0049] The field value of the time field of the record mentioned in the embodiment of the present application may be the time when the record is stored in the data table, or the time when the record is generated.
[0050] Exemplarily, the query information may be input by a user through a user interface displayed by an electronic device.
[0051] In an optional implementation, before the user inputs query information through the electronic device, the user needs to construct an application permission request through the electronic device, and the application permission request includes the data table name and the data range. After receiving the application permission request, the server verifies the application permission request. If the application permission request is approved, a globally unique query interface ID is assigned; and the corresponding relationship between the data table name, data range and query interface ID in the application permission request is constructed. Since the query interface ID corresponds to the data table name and data range, the query interface ID is the ID corresponding to the data range with query permission.
[0052] Exemplarily, the permission request may also carry a user account, so that the target user level corresponding to the user account carried in the permission request can be found from the correspondence between the preset user account and the user level; the target permission range corresponding to the target user level can be found from the correspondence between the preset user level and the permission range; if the target permission range includes the data table name and data range carried in the permission request, the permission request is approved, otherwise, the permission request is rejected.
[0053] Exemplarily, the permission application request may be reviewed manually.
[0054] The following example illustrates a request for permission. Exemplarily, the data range includes: a field and / or a sub-time interval.
[0055] For example, if a user needs to query all data in field 1 and field 2 in a table named AAA, the table name in the permission request is "AAA" and the data range is "field 1 and field 2".
[0056] For example, the time interval formed by the field values of the time field in the records contained in the table named BBB is [20110101, 20240312]. If the user needs to query the data in the table named BBB whose field values of the time field are [20190101, 20240312] ([20190101, 20240312] is a sub-time interval of [20110101, 20240312]), the table name in the permission request is "BBB" and the data range is "sub-time interval [20190101, 20240312]".
[0057] The above description uses the example that the minimum time dimension of the time interval is "day". By way of example, the minimum time dimension of the time interval may be hours, seconds, milliseconds, or centiseconds, which may be determined based on actual conditions.
[0058] Exemplarily, in the “correspondence between data table name, data range and query interface ID”, different query interface IDs correspond to different data table names.
[0059] Exemplarily, the query condition may also include a query field.
[0060] Exemplarily, the query condition may not include a data table name, because the target query interface ID corresponds to a corresponding data table name.
[0061] Exemplarily, the query condition may include a data table name.
[0062] Step S202: searching for the target data table name and the target data range corresponding to the target query interface ID from the preset correspondence relationship among the query interface ID, the data table name and the data range.
[0063] The data range corresponding to the data table name includes: a sub-time interval of a time interval formed by field values of one or more fields and a time field in the data table having the data table name.
[0064] The target query interface ID is allocated after the permission request is approved, and the permission request includes a user account, the target data table name, and the target data range corresponding to the target data table name.
[0065] The following example illustrates the above data range.
[0066] Assume that a data table includes multiple records, and the time interval of the field value of the time field in the records contained in the table named BBB is [20110101, 20240312]. The table named BBB includes field 3, field 4, field 5, field 6, and field 7. The data range can be: the field value of the time field belongs to the sub-time interval [20190101, 20240312], field 3, field 4; this data range indicates that the user has the authority to query the data in the BBB table whose field value of the time field belongs to the sub-time interval [20190101, 20240312] and is located in field 3 and field 4.
[0067] In summary, the data range corresponding to the data table name refers to the query permission for the fields contained in the data table with the data table name and the query permission for the sub-time interval in the data table with the data table name.
[0068] Step S203: If the query condition belongs to the target data range, the target data table name and the target database identifier corresponding to the query time range are searched from the preset correspondence relationship between the data table name, time range and database identifier.
[0069] Exemplarily, the number of target database identifiers may be one or more.
[0070] It is understandable that if the query condition belongs to the target data range, it means that the user has the authority to query; if the query condition does not belong to the target data range, it means that the user does not have the authority to query and the query information may not be responded to.
[0071] In an optional implementation, different records in the same data table may be stored in different databases. The applicant has found through research that different data tables all contain time fields. If the field values of the time fields of different records in the same data table are different (exemplarily, the units of the field values of the time fields can be accurate to centiseconds), the "correspondence between data table name, time range and database identifier" of each data table can be constructed by the following method, which includes the following steps A11 to A13.
[0072] Step A11: Obtain query frequencies corresponding to multiple records in the data table.
[0073] Exemplarily, the query frequency of each record is obtained through big data statistics.
[0074] Exemplarily, the query frequency of any record refers to the sum of the number of times the record is queried by various users within a preset time range.
[0075] For example, the preset time range may be determined based on actual conditions, for example, the preset time range may be [current time - preset duration, current time]. For example, the preset duration may be determined based on actual conditions, which is not limited here.
[0076] Step A12: for each record in the data table, determine the database identifier corresponding to the query frequency range to which the query frequency of the record belongs as the database identifier corresponding to the record; different database identifiers correspond to different query frequency ranges.
[0077] Step A13: For each of the records, a correspondence between the data table name of the data table, the field value of the time field of the record and the database identifier corresponding to the record is constructed.
[0078] Since the field value of the time field is used to determine the database identifier of the database storing a certain record, the query condition in the query information needs to include the query time range.
[0079] In an optional implementation, different records in the same data table may be stored in different databases. The applicant has found through research that different data tables all contain time fields. If the field value of the time field represents the time when the record is generated or the time when it is stored in the database, it has been found through research that the earlier the field value of the time field, the fewer times the record is queried. Therefore, the field value of the time field can represent the query frequency to a certain extent. Therefore, the "correspondence between data table name, time range and database identifier" of each data table can be constructed by the following method. The method includes the following steps A21 to A23.
[0080] Step A21: Obtain the field values of the time fields corresponding to the multiple records in the data table.
[0081] Step A22: for each record in the data table, determine the database identifier corresponding to the set threshold range to which the field value of the time field of the record belongs as the database identifier corresponding to the record; different database identifiers correspond to different set threshold ranges.
[0082] The following examples are used to illustrate. Assuming that the data is divided into hot data, warm data, cold data, and worthless data, the set threshold range corresponding to the hot database storing hot data is [current time-first value, current time], the set threshold range corresponding to the warm database storing warm data is [current time-2*first value, current time-first value), the set threshold range corresponding to the cold database storing cold data is [current time-3*first value, current time-2*first value), and the set threshold range corresponding to the worthless database storing worthless data is [current time-4*first value, current time-3*first value).
[0083] If the field value of the time field of a record belongs to [current time-2*first value, current time-first value), the database identifier of the record is the database identifier of the warm database.
[0084] Exemplarily, the first value may be in any unit of year, month, or day.
[0085] Step A23: For each of the records, a correspondence between the data table name of the data table, the field value of the time field of the record and the database identifier corresponding to the record is constructed.
[0086] Since the field value of the time field is used to determine the database identifier of the database storing a certain record, the query condition in the query information needs to include the query time range.
[0087] Step S204: searching for a target query statement template corresponding to the target database identifier from the preset correspondence relationship between the database identifier and the query statement template.
[0088] Exemplarily, assuming that the records contained in the data table are divided into hot data, warm data, cold data, and worthless data, the types of the hot database storing hot data, the warm database storing warm data, the cold database storing cold data, and the worthless database storing worthless data may be completely different, or partially different.
[0089] It is understandable that different types of databases have different query statements. Based on this, a correspondence between database identifiers and query statement templates is pre-constructed.
[0090] The following example illustrates that if the database is a HIVE database, the query statement template can be: SELECT [query condition] FROM [data table name].
[0091] The location of the query condition is represented by "[query condition]", and the location of the data table name is represented by "[data table name]". In practice, there may be no such identifiers. For example, the query statement template is: SELECT FROM.
[0092] Step S205: Fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement.
[0093] Exemplarily, the target query statement template includes a data table name replacement symbol and a query condition replacement symbol. In this case, step S205 is specifically as follows: fill the target data table name into the data table name replacement symbol, and fill the query condition into the data table name replacement symbol to obtain the query statement.
[0094] Exemplarily, the data table name replacement character can be represented by "[data table name]", and the query condition replacement character can be represented by "[query condition]".
[0095] Step S206: obtaining a query result from a database having the target database identifier through the query statement.
[0096] In an optional implementation, the permission application request also includes a feedback path for the query result, and further includes: sending the query result to an electronic device according to the feedback path, and the electronic device is the sender of the query information.
[0097] Exemplarily, the feedback pathway includes, but is not limited to: the format of the query result, and the communication method between the server and the electronic device.
[0098] The embodiment of the present application provides a data query method. Before querying data, it is necessary to apply for a data range, that is, to apply for records that the user can query by applying for permission. The permission request includes the data table name and the data range corresponding to the data table name. If the permission request is approved, the corresponding relationship between the query interface ID, the data table name and the data range can be constructed. If the user needs to query data, he can enter the query information, which includes the target query interface ID and the query conditions, and the query conditions include the query time range; from the preset query interface ID, the corresponding relationship between the data table name and the data range, find the target data table name and the target data range corresponding to the target query interface ID; if the query condition belongs to the target data range, it means that within the user's query authority, since different records in the same data table may be stored in different databases, it is necessary to find the target data table name and the target database identifier corresponding to the query time range from the preset data table name, the corresponding relationship between the time range and the database identifier; thereby determining which databases need to be used to obtain the query results; from the preset database identifier and the corresponding relationship between the query statement template, find the target query statement template corresponding to the target database identifier; fill the target data table name and the query conditions into the corresponding position of the target query statement template to obtain the query statement; obtain the query results from the database with the target database identifier through the query statement. In this application, when querying records, the user only needs to enter the query information, without having to know which databases the records to be queried belong to, and without having to construct a query statement for each database, thereby making the query operation simple.
[0099] It is understandable that, as time passes, the query frequency of records in the data table may change, for example, hot data becomes warm data, cold data or worthless data, and warm data becomes hot data, cold data or worthless data. Therefore, it is necessary to archive the records stored in the database, and the process includes the following steps B11 to B13.
[0100] Step B11: set a time interval at each interval to obtain query frequencies corresponding to multiple records in the data table.
[0101] For example, the duration can be set based on actual conditions, which will not be elaborated here.
[0102] Exemplarily, the query frequency of each record is obtained through big data statistics.
[0103] Exemplarily, the query frequency of any record refers to the sum of the number of times the record is queried by various users within a preset time range.
[0104] For example, if the field value of the time field represents the time when the record is generated or stored in the database, research has found that the earlier the field value of the time field, the fewer times the record is queried, so the field value of the time field can represent the query frequency to a certain extent.
[0105] Step B12: If the query frequency range to which the query frequency of the target record in the multiple records of the data table belongs is changed from the first query frequency range to the second query frequency range, the target record stored in the first database having a database identifier corresponding to the first query frequency range is copied to the second database having a database identifier corresponding to the second query frequency range.
[0106] Exemplarily, if the field value of the time field represents the query frequency, the query frequency range has the same meaning as the set threshold range.
[0107] Step B13: If the target record in the first database is the same as the target record in the second database, delete the target record in the first database.
[0108] It is understandable that if the database storing the records changes, the correspondence between the data table name, time range and database identifier needs to be updated.
[0109] The method is described in detail in the embodiments disclosed in the above-mentioned application. The method of the application can be implemented by various forms of devices. Therefore, the application also discloses a device, and a specific embodiment is given below for detailed description.
[0110] Figure 3 is a block diagram of a data query device according to an exemplary embodiment. Figure 3 The device includes: a first acquisition module 31, a first search module 32, a second search module 33, a third search module 34, a second acquisition module 35 and a third acquisition module 36, wherein:
[0111] A first acquisition module 31 is used to acquire query information, wherein the query information includes a target query interface ID and a query condition, wherein the query condition includes a query time range, and the target query interface ID refers to an ID corresponding to a data range with query authority;
[0112] The first search module 32 is used to search for the target data table name and the target data range corresponding to the target query interface ID from the preset correspondence relationship between the query interface ID, the data table name and the data range; the data range corresponding to the data table name includes a sub-time interval of the time interval composed of one or more fields in the data table with the data table name and the field value of the time field;
[0113] The target query interface ID is allocated after the permission request is approved, and the permission request includes the target data table name and the target data range corresponding to the target data table name;
[0114] A second search module 33 is used to search for the target data table name and the target database identifier corresponding to the query time range from the preset correspondence relationship between the data table name, the time range and the database identifier if the query condition belongs to the target data range;
[0115] A third search module 34 is used to search for a target query statement template corresponding to the target database identifier from a preset correspondence relationship between database identifiers and query statement templates;
[0116] The second acquisition module 35 is used to fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement;
[0117] The third acquisition module 36 is used to acquire the query result from the database having the target database identifier through the query statement.
[0118] In an optional implementation, the data table includes multiple records, and for each data table, further includes:
[0119] A fourth acquisition module is used to acquire query frequencies corresponding to a plurality of records in the data table;
[0120] A first determination module is used to determine, for each record in the data table, that the database identifier corresponding to the query frequency range to which the query frequency of the record belongs is the database identifier corresponding to the record; different database identifiers correspond to different query frequency ranges;
[0121] A relationship building module is used to build, for each of the records, a corresponding relationship between the data table name of the data table, the field value of the time field of the record and the database identifier corresponding to the record.
[0122] In an optional implementation, the query frequency of the record is represented by a field value of a time field of the record, and the query frequency range is represented by a set time range; or,
[0123] The query frequency of the record is the sum of the number of times the record is queried by each user within a preset time range.
[0124] In an optional implementation, the method further includes:
[0125] A fifth acquisition module, configured to acquire query frequencies corresponding to a plurality of records in the data table at set intervals of time;
[0126] a copy module, for copying the target record stored in the first database having a database identifier corresponding to the first query frequency range to the second database having a database identifier corresponding to the second query frequency range if the query frequency range to which the query frequency of the target record in the multiple records of the data table belongs is changed from the first query frequency range to the second query frequency range;
[0127] A deleting module is used to delete the target record in the first database if the target record in the first database is the same as the target record in the second database.
[0128] In an optional implementation, the target query statement template includes a data table name replacement symbol and a query condition replacement symbol, and the second acquisition module 35 is specifically used to: fill the target data table name into the data table name replacement symbol, and fill the query condition into the data table name replacement symbol to obtain the query statement.
[0129] In an optional implementation, the permission application request also includes a feedback path for the query result, and also includes:
[0130] The sending module is used to send the query result to the electronic device according to the feedback path, and the electronic device is the sending end of the query information.
[0131] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0132] Figure 4 The invention is a block diagram showing a device for a server according to an exemplary embodiment.
[0133] The server includes, but is not limited to, a processor 41 , a memory 42 , a network interface 43 , an I / O controller 44 , and a communication bus 45 .
[0134] It should be noted that those skilled in the art can understand that Figure 4 The server structure shown in the figure does not constitute a limitation on the server, and the server may include Figure 4 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0135] Combine the following Figure 4 A detailed introduction to the various components of the server:
[0136] The processor 41 is the control center of the server. It uses various interfaces and lines to connect various parts of the entire server. It executes various functions of the server and processes data by running or executing software programs and / or modules stored in the memory 42, and calling data stored in the memory 42, so as to monitor the server as a whole. The processor 41 may include one or more processing units; illustratively, the processor 41 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 41.
[0137] The processor 41 may be a central processing unit (CPU), or an application specific integrated circuit ASIC (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention, etc.;
[0138] The memory 42 may include a memory, such as a high-speed random access memory (RAM) 421 and a read-only memory (ROM) 422, and may also include a large-capacity storage device 423, such as at least one disk storage, etc. Of course, the server may also include hardware required for other services.
[0139] The memory 42 is used to store instructions executable by the processor 41. The processor 41 has the function of executing the data query method.
[0140] A wired or wireless network interface 43 is configured to connect the server to the network.
[0141] The processor 41, the memory 42, the network interface 43 and the I / O controller 44 may be interconnected via a communication bus 45, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc.
[0142] In an exemplary embodiment, the server 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 execute the above-mentioned data query method.
[0143] In an exemplary embodiment, the present disclosure provides a storage medium including instructions, such as a memory 42 including instructions, and the instructions can be executed by a processor 41 of a server to complete the above method. Optionally, the storage medium can be a non-transitory computer-readable storage medium, for example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0144] In an exemplary embodiment, a computer-readable storage medium is also provided, which can be directly loaded into the internal memory of a computer, such as the above-mentioned memory 42, and contains software code. After the computer program is loaded and executed, the above-mentioned data query method can be implemented.
[0145] In an exemplary embodiment, a computer program product is also provided, which can be directly loaded into the internal memory of a computer, such as the memory included in the server, and contains software code. After being loaded and executed by the computer, the computer program can implement the above-mentioned data query method.
[0146] It should be noted that the data query method, device, server, medium and product provided by the present invention can be used in the field of big data or finance. The above is only an example and does not limit the application field of the data query method provided by the present invention.
[0147] It should be noted that the features described in the various embodiments in this specification can be replaced or combined with each other. For the device or system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0148] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0149] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0150] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data query method, characterized in that: include: Acquire query information, the query information including a target query interface ID and query conditions, the query conditions including a query time range, and the target query interface ID refers to an ID corresponding to a data range with query authority; From the preset correspondence between the query interface ID, the data table name and the data range, searching for the target data table name and the target data range corresponding to the target query interface ID; the data range corresponding to the data table name includes a sub-time interval of a time interval consisting of one or more fields in the data table having the data table name and the field value of the time field; The target query interface ID is allocated after the permission request is approved, and the permission request includes the target data table name and the target data range corresponding to the target data table name; If the query condition belongs to the target data range, searching for the target data table name and the target database identifier corresponding to the query time range from the preset correspondence between the data table name, time range and database identifier; Searching for a target query statement template corresponding to the target database identifier from a preset correspondence relationship between the database identifier and the query statement template; Fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement; The query result is obtained from the database having the target database identifier through the query statement.
2. The data query method according to claim 1, characterized in that: The data table includes multiple records. For each data table, the method for obtaining the corresponding relationship between the data table name, the time range and the database identifier includes: Obtain query frequencies corresponding to multiple records in the data table; For each record in the data table, determine that the database identifier corresponding to the query frequency range to which the query frequency of the record belongs is the database identifier corresponding to the record; different database identifiers correspond to different query frequency ranges; For each of the records, a correspondence between the data table name of the data table, the field value of the time field of the record and the database identifier corresponding to the record is constructed.
3. The data query method according to claim 2, characterized in that: The query frequency of the record is represented by the field value of the time field of the record, and the query frequency range is represented by a set time range; or, The query frequency of the record is the sum of the number of times the record is queried by each user within a preset time range.
4. The data query method according to any one of claims 2 or 3, characterized in that: Also includes: At each interval of a set duration, the query frequencies corresponding to the multiple records in the data table are obtained; If the query frequency range to which the query frequency of the target record in the plurality of records of the data table belongs is changed from the first query frequency range to the second query frequency range, the target record stored in the first database having the database identifier corresponding to the first query frequency range is copied to the second database having the database identifier corresponding to the second query frequency range; If the target record in the first database is the same as the target record in the second database, the target record in the first database is deleted.
5. The data query method according to claim 1, characterized in that: The target query statement template includes a data table name replacement symbol and a query condition replacement symbol. The step of filling the target data table name and the query condition into corresponding positions of the target query statement template to obtain a query statement includes: The target data table name is filled into the data table name replacement character, and the query condition is filled into the data table name replacement character to obtain the query statement.
6. The data query method according to claim 1, characterized in that: The permission application request also includes a feedback path for the query results, and also includes: The query result is sent to an electronic device according to a feedback path, and the electronic device is a sending end of the query information.
7. A data query device, characterized in that: include: A first acquisition module is used to acquire query information, wherein the query information includes a target query interface ID and a query condition, wherein the query condition includes a query time range, and the target query interface ID refers to an ID corresponding to a data range with query authority; A first search module is used to search for a target data table name and a target data range corresponding to the target query interface ID from a preset correspondence relationship between the query interface ID, the data table name and the data range; the data range corresponding to the data table name includes a sub-time interval of a time interval consisting of one or more fields in a data table having the data table name and a field value of a time field; The target query interface ID is allocated after the permission request is approved, and the permission request includes the target data table name and the target data range corresponding to the target data table name; A second search module is used to search for the target data table name and the target database identifier corresponding to the query time range from the preset correspondence relationship between the data table name, time range and database identifier if the query condition belongs to the target data range; A third search module, used to search for a target query statement template corresponding to the target database identifier from a preset correspondence relationship between the database identifier and the query statement template; A second acquisition module, used to fill the target data table name and the query condition into the corresponding position of the target query statement template to obtain a query statement; The third acquisition module is used to acquire the query result from the database having the target database identifier through the query statement.
8. A server comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Data query method and device, server and storage medium
CN112052267A
Target query statement construction method and device, storage medium and electronic device
CN113127506A
Data query method and device, storage medium and computer equipment
CN114880329A
Data query method and device, electronic equipment and storage medium
CN115129741A
Data query method, system and device, medium and product
CN116049221A
