Method and apparatus for obtaining execution information of SQLite

By obtaining the call parameters of the SQLite performance tuning interface and registering callback functions, the problems of large code volume and business stability in existing technologies are solved, and efficient acquisition of SQLite execution information is achieved.

CN113392120BActive Publication Date: 2026-02-06TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010171991.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-12
Publication Date
2026-02-06
Estimated Expiration
2040-07-26

AI Technical Summary

Technical Problem

Existing technologies require manual code writing for each SQLite execution, resulting in large amounts of code, poor versatility, and impact on business stability.

Method used

By obtaining the call parameters of the SQLite performance tuning interface, a callback function is registered to obtain execution information, thus avoiding the need to modify the business logic code.

Benefits of technology

It reduces the amount of code, improves retrieval efficiency, has good versatility, and does not affect business stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113392120B_ABST
    Figure CN113392120B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for obtaining execution information of SQLite, and belongs to the technical field of computers. According to the embodiment of the application, the calling parameter of a performance tuning interface is set as a performance tuning interface of SQLite, a callback function is registered in SQLite by calling the performance tuning interface, and when SQLite is called, the execution information can be called back to the registered callback function, so that the execution information can be obtained without changing the original business logic code, thereby greatly reducing the code amount, reducing the labor cost, and effectively improving the acquisition efficiency. Since the original business logic code does not need to be changed, the acquisition of the execution information can be realized when any business logic calls SQLite, the generality is good, and the stability of the business is not affected.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a method and device for obtaining execution information of SQLite. BACKGROUND

[0002] SQLite is a database widely used in Android programs, and the use quality of SQLite directly affects the experience of some applications. For example, a time-consuming query may cause the response delay or lag of a program page. Therefore, it is usually necessary to obtain the execution information of SQLite in a device to analyze whether there is a SQL statement with long time consumption.

[0003] At present, the method for obtaining the execution information of SQLite is usually realized by dotting statistics. Specifically, the developer writes the code for SQLite execution information statistics each time the SQLite is executed when writing the code, so that the execution information can be counted and reported when the code is executed.

[0004] The above method needs the developer to add the corresponding code at each SQLite execution when writing the code, so the code amount is large. Different applications or businesses need their own developers to write the corresponding code according to their own code characteristics, which has poor universality and affects the stability of the business because the original business logic code needs to be changed. Therefore, the above method has poor universality and low efficiency. SUMMARY

[0005] The embodiment of the present application provides a method and device for obtaining the execution information of SQLite, which can improve the efficiency and the checking efficiency. The technical scheme is as follows:

[0006] On one hand, a method for obtaining the execution information of SQLite is provided, which comprises:

[0007] In response to a SQLite connection instruction, obtaining the calling parameter of the performance tuning interface of SQLite, the calling parameter being used to indicate calling the performance tuning interface of SQLite;

[0008] According to the calling parameter, calling the performance tuning interface of SQLite, and registering the callback function to SQLite through the performance tuning interface;

[0009] In response to the calling instruction of SQLite, according to the registered callback function in SQLite, calling the execution information of SQLite to the callback function to obtain the execution information of SQLite.

[0010] In an aspect, an apparatus for obtaining execution information of SQLite is provided, the apparatus comprising:

[0011] an obtaining module configured to obtain, in response to a SQLite connection instruction, a calling parameter of a performance tuning interface of SQLite, the calling parameter being used to indicate calling the performance tuning interface of the SQLite;

[0012] a calling module configured to call the performance tuning interface of the SQLite according to the calling parameter, and register a callback function to the SQLite through the performance tuning interface;

[0013] the calling module is further configured to, in response to a calling instruction of the SQLite, call the execution information of the SQLite to the callback function according to the callback function registered in the SQLite, and obtain the execution information of the SQLite.

[0014] In a possible implementation, the debugging class is an android.database.sqlite.SQLiteDebug class.

[0015] the performance tuning interface is a sqlite3_profile interface, and the calling parameter is a DEBUG_SQL_TIME variable; or, the performance tuning interface is a sqlite3_trace interface, and the calling parameter is a DEBUG_SQL_STATEMENTS.

[0016] In a possible implementation, the apparatus further comprises a sending module, the sending module being configured to perform any one of the following:

[0017] send the execution information of the SQLite to a target device;

[0018] analyze the execution information of the SQLite, and send the execution information of the SQLite meeting a target condition to a target device.

[0019] In a possible implementation, the execution information of the SQLite comprises at least one structured query language (SQL) statement and an execution duration of each SQL statement.

[0020] the sending module is configured to:

[0021] obtain the execution duration of at least one SQL statement in the execution information of the SQLite;

[0022] in response to the execution duration of any SQL statement being greater than a duration threshold, send the SQL statement to a target device.

[0023] In an aspect, an electronic device is provided, which includes one or more processors and one or more memories having at least one program code stored therein, which is loaded and executed by the one or more processors to implement operations performed by the method of obtaining execution information of SQLite according to any possible implementation as described above.

[0024] In an aspect, a storage medium is provided, which has at least one program code stored therein, which is loaded and executed by a processor to implement operations performed by the method of obtaining execution information of SQLite according to any possible implementation as described above.

[0025] The technical scheme provided by the embodiments of the present application brings at least the following beneficial effects:

[0026] The embodiments of the present application set the calling parameter of the performance tuning interface as the performance tuning interface of SQLite, register a callback function in SQLite by calling the performance tuning interface, and call the registered callback function to return execution information when SQLite is called, so that the execution information can be obtained without changing the original business logic code, thereby greatly reducing the code amount, reducing the labor cost, and effectively improving the acquisition efficiency. Since the original business logic code does not need to be changed, the execution information can be obtained when any business logic calls SQLite, which has good universality and does not affect the stability of the business. BRIEF DESCRIPTION OF DRAWINGS

[0027] In order to more clearly illustrate the technical scheme in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0028] Figure 1 is an implementation environment of the method for obtaining execution information of SQLite provided by the embodiments of the present application;

[0029] Figure 2 is a flowchart of the method for obtaining execution information of SQLite provided by the embodiments of the present application;

[0030] Figure 3 is an implementation environment of the method for obtaining execution information of SQLite provided by the embodiments of the present application;

[0031] Figure 4 is a flowchart of the method for obtaining execution information of SQLite provided by the embodiments of the present application;

[0032] Figure 5 is a structural schematic diagram of a device for obtaining execution information of SQLite provided by an embodiment of the present application;

[0033] Figure 6 is a structural schematic diagram of a terminal provided by an embodiment of the present application;

[0034] Figure 7 is a structural schematic diagram of a server provided by an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the present application clearer, the embodiments of the present application will be further described in detail below with reference to the drawings.

[0036] In the present application, the terms "first", "second" and the like are used to distinguish the same or similar items with substantially the same function and action, and it should be understood that there is no logical or time sequence relationship between "first", "second", "nth", and the number and execution order are not limited.

[0037] In the present application, the term "at least one" means one or more, and the term "multiple" means two or more, for example, multiple first positions means two or more first positions.

[0038] In the following, the terms related to the present application are explained.

[0039] SQLite, a lightweight file database widely used in mobile terminals and clients, is a relational database management system complying with ACID (Atomicity, Consistency, Isolation, Durability).

[0040] SQLite3: version 3 of SQLite, which is currently widely used.

[0041] Execution information of SQLite: mainly refers to the executed Structured Query Language (SQL) statements and their time consumption.

[0042] Hook: also known as "hook", is a computer programming term, which refers to various techniques for modifying or extending the behavior of operating systems, application programs or other software components by intercepting function calls, message passing, event passing between software modules. The code that handles the intercepted function calls, events, messages is called hook.

[0043] Slow SQL: a SQL statement with long execution time.

[0044] Application: can refer to an upper layer application on Android, that is, an Android App. APP is an abbreviation of Application, which refers to an application program.

[0045] Non-invasive: when accessing a certain solution, the business code itself does not need to be modified or affected.

[0046] Callback function: a function called through a function pointer. If you pass the pointer (address) of a function as a parameter to another function, when this pointer is used to call the function it points to, we say it is a callback function. The callback function is not directly called by the implementer of the function, but is called by another party when a specific event or condition occurs, for responding to the event or condition.

[0047] Figure 1 FIG. 1 is a schematic diagram of an implementation environment of a method for obtaining execution information of SQLite provided by an embodiment of the present application. The implementation environment includes a terminal 101 and a detection platform 102. The terminal 101 is connected to the detection platform 102 through a wireless network or a wired network.

[0048] The terminal 101 can be at least one of a smart phone, a game console, a desktop computer, a tablet computer, an e-book reader, an MP3 (Moving Picture Experts Group Audio Layer III) player, an MP4 (Moving Picture Experts Group Audio Layer IV) player, and a laptop computer. The terminal 101 is installed and runs at least one application program, for example, the application program can be an instant messaging application, a news push application, a shopping application, an online video application, and a social application. The terminal 101 can include SQLite, and the terminal 101 can implement local storage through the SQLite. When implementing the business logic of the application program, the SQLite can be called to perform corresponding functions. In a possible implementation manner, the terminal 101 can obtain and report the execution information of the SQLite to the detection platform 102 when the SQLite is called.

[0049] The detection platform 102 comprises at least one of a server, multiple servers, a cloud computing platform and a virtualization center. The detection platform 102 is configured to provide background services for the execution information provided by the terminal 101. Optionally, the detection platform 102 comprises a server 1021 and a database 1022. The server 1021 is configured to provide background services related to the execution information of SQLite. The server 1021 can be one or multiple. When the server 1021 is multiple, there are at least two servers 1021 configured to provide different services, and / or there are at least two servers 1021 configured to provide the same service, such as providing the same service in a load balancing manner, which is not limited in the embodiments of the present application. The database 1022 stores data required for processing tasks. When the server 1021 needs data, the database 1022 can be accessed to read the data stored in the database 1022. When the server processes tasks and obtains information related to the execution information, the information can be written into the database 1022, so as to store the information persistently through the database 1022.

[0050] It is known to those skilled in the art that the number of the terminal 101 and the server 1021 can be more or less. For example, the terminal 101 and the server 1021 can be only one, or the terminal 101 and the server 1021 can be dozens or hundreds, or more, which are not limited in the embodiments of the present application.

[0051] SQLite itself provides a performance tuning interface, from which a callback can be registered to obtain the execution statement and the time consumption of SQLite. The Android framework itself also has a code of calling sqlite3_profile, but generally does not call and expose to the upper application by default, so that the execution information of SQLite cannot be obtained. In the embodiments of the present application, the calling parameters of the performance tuning interface are modified, so that the framework calls the performance tuning interface, and registers a callback function in SQLite by calling the performance tuning interface, so that the execution information of SQLite can be called back to the registered callback function when SQLite is called, that is, the execution information of SQLite can be obtained.

[0052] Figure 2 is a flowchart of the method for obtaining the execution information of SQLite provided by the embodiments of the present application, which is applied to an electronic device, and the method can comprise the following steps: Figure 2

[0053] 201. The electronic device loads a debugging class of SQLite in response to a parameter configuration instruction.

[0054] ​The electronic device can assign a call parameter of SQLite through steps 201 to 203, so that the assigned call parameter is used to indicate a call performance tuning interface.

[0055] The parameter configuration instruction is used to indicate that the call parameter of the performance tuning interface is assigned. The parameter configuration instruction can be triggered by a related technical person according to a requirement, or triggered by a user when the user wants to obtain the execution information of SQLite. The triggering condition of the parameter configuration instruction is not limited in the embodiment of the application. The debugging class is used to provide a group of methods and properties that help to debug code. The call parameter is a variable of an object in the debugging class.

[0056] After the electronic device receives the parameter configuration instruction, the electronic device can load a debugging class of SQLite in response to the parameter configuration instruction, so as to subsequently find the call parameter in the debugging class and assign the call parameter.

[0057] In a possible implementation manner, the method for obtaining the execution information of SQLite can be applied to different operating systems, for example, an Android or IOS operating system. Here, the application to the Android platform is taken as an example for description.

[0058] The execution information of SQLite can be obtained through a plurality of performance tuning interfaces, and accordingly, the call parameter configured in the configuration step can be different. For the debugging class, the performance tuning interface and the call parameter, the debugging class can be an android.database.sqlite.SQLiteDebug class. The performance tuning interface is a sqlite3_profile interface or a sqlite3_trace interface. When the performance tuning interface is the sqlite3_profile interface, the call parameter is a DEBUG_SQL_TIME variable. When the performance tuning interface is the sqlite3_trace interface, the call parameter can be a DEBUG_SQL_STATEMENTS. Of course, the debugging class, the performance tuning interface and the call parameter can also be set by a related technical person according to the information of the device. The above is only a few exemplary descriptions, and the embodiment of the application is not limited thereto.

[0059] 202. The electronic device obtains the call parameter declared by the debugging class.

[0060] After the electronic device loads the debugging class, the electronic device can obtain each parameter declared in the debugging class, and the call parameter is one of the parameters. Specifically, the electronic device can obtain all the parameters declared by the debugging class, query the call parameter from all the parameters according to the name of the call parameter, and obtain the call parameter.

[0061] The calling parameter is obtained in this way, and the following step 203 is performed to assign a value to the calling parameter to realize the calling of the performance tuning interface when the SQLite is called.

[0062] 203. The electronic device assigns a value to the calling parameter, and the calling parameter after the assignment is used to indicate the calling of the performance tuning interface of the SQLite.

[0063] After the electronic device obtains the calling parameter, the electronic device can assign a value to the calling parameter to set the calling parameter to indicate the calling of the performance tuning interface of the SQLite.

[0064] For example, the calling parameter is a variable DEBUG_SQL_TIME in the android.database.sqlite.SQLiteDebug class, and the variable (calling parameter) is false by default, indicating that the performance tuning interface is not called. The electronic device can assign a value to the variable to modify the variable to true, so that the variable after the assignment is used to indicate the calling of the performance tuning interface, and the performance tuning interface is called when the SQLite is connected subsequently.

[0065] It should be noted that the above steps 201 to 203 are the process of assigning a value to the calling parameter of the performance tuning interface to enable the calling of the performance tuning interface when the SQLite is connected. The above provides a possible assignment manner, and the process can also be implemented in the Java reflection manner or other manners, which is not limited in the embodiments of the present application.

[0066] 204. The electronic device replaces the performance tuning interface in the runtime library of the device with a target interface.

[0067] The runtime library is a built-in function of a programming language used by a compiler to implement the language, which can be a special computer program library that provides support for the running or execution of a language program. For example, in the Android operating system, the runtime library can be libandroid_runtime.so.

[0068] The electronic device can replace the performance tuning interface in the runtime library with the target interface, and the system framework can call the target interface when the SQLite is connected. For example, taking the performance tuning interface as the sqlite3_profile interface as an example, the target interface can be named as my_hooked_sqlite3_profile, and the performance tuning interface sqlite3_profile in the runtime library libandroid_runtime.so is replaced with the target interface my_hooked_sqlite3_profile. If the replacement does not occur, the system framework can call the performance tuning interface when the SQLite is connected.

[0069] It should be noted that the performance tuning interface is an interface provided by SQLite itself, and if the performance tuning interface is directly called, the performance tuning interface will send the obtained execution information of SQLite to a function of the system itself, and the function will not be exposed to the upper application, so the execution information cannot be obtained. Therefore, by performing the replacing step, the called interface is replaced with the target interface, the performance tuning interface is called through an external interface, and by the registered callback function in the following steps, the execution information of SQLite obtained by SQLite when calling is called back to the registered callback function, and the execution information of SQLite can be obtained.

[0070] Specifically, the replacing process can be implemented in various ways. In one possible implementation, the replacing process can be implemented in the form of an elf hook, where elf is an executable and linkable format, which is a standard file format for executable files, object files, shared libraries and core dumps. In the above replacing process, the electronic device can intercept the elf file and modify the data therein. Of course, other ways can also be used to replace, and the embodiments of the present application do not limit this.

[0071] 205、The electronic device obtains the calling parameter of the performance tuning interface of SQLite in response to the SQLite connection instruction, and the calling parameter is used to indicate calling the performance tuning interface of SQLite.

[0072] When the electronic device receives the SQLite connection instruction, the electronic device can obtain the calling parameter of the performance tuning interface in response to the SQLite connection instruction, to determine whether the performance tuning interface of SQLite needs to be called. The calling parameter has been assigned in step 203, and after being assigned, it indicates calling the performance tuning interface of SQLite, so the electronic device can perform the following step 206.

[0073] In one possible implementation, the function of opening and closing can also be provided for the function of obtaining the execution information of SQLite. The above steps 201 to 203 are the process of opening the function, and after the function is opened, the electronic device can perform steps 204 to 207 to register the callback function to SQLite, so as to obtain the execution information of SQLite when calling SQLite subsequently.

[0074] Correspondingly, the electronic device can also close the function of acquiring the execution information of SQLite according to the closing instruction of the function of acquiring the execution information of SQLite. Specifically, the electronic device can execute the same steps as steps 201 to 206 in response to the closing instruction of the function of acquiring the execution information of SQLite, set the calling parameter as calling SQLite, register a new callback function in SQLite when connecting to SQLite, the new callback function can be a function inside the system, or delete the callback function registered in step 206, thereby closing the execution information acquisition function.

[0075] 206、The electronic device calls the target interface according to the calling parameter.

[0076] Since the performance tuning interface in the runtime library has been replaced by the target interface in the above step 204, the electronic device can call the target interface according to the calling parameter, and then call the performance tuning interface through the target interface. In this way, it can be avoided to directly call the performance tuning interface and call the execution information of SQLite to the function inside the system.

[0077] 207、The electronic device calls the performance tuning interface of the SQLite through the target interface, and registers the callback function in the SQLite.

[0078] The electronic device can call the performance tuning interface through the target interface. The target interface includes information of the performance tuning interface, which is used to indicate the calling of the performance tuning interface.

[0079] The electronic device can call the performance tuning interface through the target interface, write the callback function into the performance tuning interface, and complete the registration of the callback function. In this way, the execution information of SQLite obtained by the performance tuning interface can be called back to the callback function registered through the target interface, instead of the function inside the system.

[0080] For example, taking the performance calling interface as the sqlite3_profile interface, and naming the target interface as my_hooked_sqlite3_profile as an example, the sqlite3_profile can be called through my_hooked_sqlite3_profile, and our own callback function can be registered in sqlite3_profile, for example, the callback function can be named as mySQLite3Profile. The execution information of SQLite can be called back to mySQLite3Profile through the callback function.

[0081] It should be noted that steps 206 and 207 above refer to the process of calling the SQLite performance tuning interface according to the calling parameters, and registering a callback function with SQLite through the performance tuning interface. By adding a target interface and calling the performance tuning interface through the target interface to register our own callback function, instead of directly calling the performance tuning interface, we can achieve the goal of receiving SQLite execution information back to our own registered callback function, instead of the system's internal function.

[0082] It should be noted that steps 201 to 207 above are configuration processes, which the electronic device can execute only once. After the configuration is completed, when the electronic device receives a call command to SQLite, it can execute the following steps to obtain the SQLite execution information.

[0083] 208. In response to the call command to SQLite, the electronic device retrieves the execution information of SQLite by calling back the callback function registered in SQLite.

[0084] Through steps 201 to 207 above, a callback function has been registered in SQLite. When the electronic device runs an application, if it needs a file in the SQLite database or wants to store a file in the SQLite database, it can call the SQLite database to execute the SQL statements and achieve the corresponding function. In this way, the electronic device can obtain the call instruction to the SQLite database. The electronic device can respond to the call instruction and execute the callback steps, thus sending the obtained SQLite execution information back to the callback function. In this way, we obtain the execution information of the SQLite database.

[0085] Specifically, the callback process can be as follows: the electronic device can respond to the call command to SQLite, obtain the execution information of SQLite, and according to the callback function registered in the SQLite, call back the execution information of SQLite to the callback function, and obtain the execution information of SQLite from the callback function.

[0086] In one possible implementation, after the electronic device obtains the SQLite execution information, it can also send the SQLite execution information to the target device, or analyze the SQLite execution information and send the SQLite execution information that meets the target conditions to the target device.

[0087] The target device is configured to process the execution information of the SQLite. For example, the target device can be a device on which the detection platform is located. The electronic device can send the execution information of the SQLite to the detection platform, and the detection platform can analyze the execution information of the SQLite or determine the SQL statement that needs to be optimized according to the execution information of the SQLite.

[0088] In a specific possible implementation, the execution information of the SQLite includes at least one structured query language (SQL) statement and an execution duration of each SQL statement. The process of analyzing and sending the execution information that meets the target condition can be: the electronic device acquires the execution duration of at least one SQL statement in the execution information of the SQLite, and in response to the execution duration of any SQL statement being greater than a duration threshold, sends the SQL statement to the target device.

[0089] A specific example is provided below, referring to Figure 3 The method provided in this application can be applied to an electronic device. When the application is running, the SQLite execution information can be collected by the above step 208 and sent to the detection platform. Thus, by using the method provided in this application, the relevant running information of SQLite3 in the program can be collected, such as the executed SQL statement and the time consumption, and the information can be detected and analyzed, such as the slow SQL, so as to improve the quality and experience of the entire mobile terminal product.

[0090] As shown in Figure 4 Before the method provided in this application is implemented, the default logic of the Android framework is: when the application creates a database connection, it is determined whether to call sqlite3_profile (a performance tuning interface), and the default is no, and if yes, a callback is registered to the internal callback function sqliteProfileCallback of the Android framework layer. In this application, by using the hook technology, the Android framework layer is modified to call sqlite3_profile, the sqlite3_profile is replaced to the hook method (my_hooked_sqlite3_profile, that is, the target interface), and the SQLite execution information callback function mySQLiteProfileCallback is registered.

[0091] The Android framework logic after the scheme is implemented can be: thus when the upper-layer application calls the Android framework interface to create a database, the my_hooked_sqlite3_profile (that is, the target interface) is called, and the sqlite3_profile is called through the target interface to register the execution information callback function mySQLite3Profile to SQLite3. In this way, the application does not need to modify any original business code, and when the application uses the database, the SQLite executes, and the SQLite will call the relevant execution information to the mySQLite3Profile (registered callback function) through the callback function. After obtaining the execution information, the execution information related information can be used, for example, it can be reported.

[0092] The method provided in the application can be accessed by the upper-layer application of Android without modification and adaptation because it is a logical change of the Android framework layer. The access cost of the method provided in the embodiment of the application is extremely low, and the single process only needs to execute the scheme once. The method is non-intrusive, that is, the original business logic code of the developer does not need to be modified. The method has good universality and is applicable to all Android applications without any adaptation. The method has comprehensive coverage and can collect all execution information of SQLite during application running.

[0093] The embodiment of the application sets the calling parameter of the performance tuning interface as the calling parameter of the performance tuning interface of SQLite, registers the callback function in SQLite by calling the performance tuning interface, so that the execution information can be called to the registered callback function when SQLite is called, the execution information can be obtained without changing the original business logic code, thereby greatly reducing the code amount, reducing the labor cost, and effectively improving the acquisition efficiency. Since the original business logic code does not need to be changed, the execution information can be obtained when any business logic calls SQLite, the method has good universality, and will not affect the stability of the business.

[0094] Figure 5 is a structural schematic diagram of a device for obtaining execution information of SQLite provided in the application, referring to Figure 5 The device comprises:

[0095] The obtaining module 501 is configured to obtain a calling parameter of a performance tuning interface of SQLite in response to a SQLite connection instruction, the calling parameter being used to indicate calling the performance tuning interface of the SQLite.

[0096] The calling module 502 is configured to call the performance tuning interface of the SQLite according to the calling parameter, and register a callback function to the SQLite through the performance tuning interface.

[0097] The calling module 502 is further configured to, in response to the calling instruction of the SQLite, call execution information of the SQLite to a callback function registered in the SQLite according to the callback function, to obtain the execution information of the SQLite.

[0098] In a possible implementation, the calling module 502 is configured to:

[0099] call the target interface according to the calling parameter;

[0100] call the performance tuning interface of the SQLite through the target interface, and register a callback function corresponding to the target interface in the SQLite.

[0101] In a possible implementation, the apparatus further includes:

[0102] a replacing module configured to replace the performance tuning interface in the runtime library of the device with the target interface.

[0103] In a possible implementation, the calling module 502 is configured to:

[0104] obtain execution information of the SQLite in response to a calling instruction of the SQLite;

[0105] call the execution information of the SQLite to a callback function registered in the SQLite according to the callback function;

[0106] obtain the execution information of the SQLite from the callback function.

[0107] In a possible implementation, the apparatus further includes:

[0108] a loading module configured to load a debugging class of the SQLite in response to a parameter configuration instruction.

[0109] The obtaining module 501 is further configured to obtain a calling parameter declared by the debugging class.

[0110] a value assigning module configured to assign a value to the calling parameter, the calling parameter after the value assignment being used to indicate calling the performance tuning interface of the SQLite.

[0111] In a possible implementation, the debugging class is an android.database.sqlite.SQLiteDebug class.

[0112] The performance tuning interface is an sqlite3_profile interface, and the calling parameter is a DEBUG_SQL_TIME variable; or the performance tuning interface is an sqlite3_trace interface, and the calling parameter is a DEBUG_SQL_STATEMENTS.

[0113] In a possible implementation, the apparatus further includes a sending module configured to perform any one of the following:

[0114] sending the execution information of the SQLite to the target device;

[0115] analyzing the execution information of the SQLite, and sending the execution information of the SQLite meeting a target condition to the target device.

[0116] In a possible implementation, the execution information of the SQLite includes at least one structured query language (SQL) statement and an execution duration of each SQL statement.

[0117] The sending module is configured to:

[0118] obtain the execution duration of at least one SQL statement in the execution information of the SQLite;

[0119] in response to the execution duration of any SQL statement being greater than a duration threshold, sending the SQL statement to the target device.

[0120] The apparatus provided by the embodiments of the present application sets the calling parameter of the performance tuning interface as a calling parameter of a performance tuning interface of SQLite, registers a callback function in SQLite by calling the performance tuning interface, and thus can call back the execution information to the registered callback function when SQLite is called, so that the execution information can be obtained without changing the original business logic code, thereby greatly reducing the code amount, reducing the labor cost, and effectively improving the acquisition efficiency. Since the original business logic code does not need to be changed, the execution information can be acquired when any business logic calls SQLite, which is good in versatility and does not affect the stability of the business.

[0121] It should be noted that the device for obtaining execution information of SQLite provided in the above embodiment is only used as an example for dividing the above function modules when checking the memory, and in actual application, the above function distribution can be completed by different function modules according to the needs, that is, the internal structure of the electronic device is divided into different function modules to complete all or part of the functions described above. In addition, the device for obtaining execution information of SQLite and the method for obtaining execution information of SQLite provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method for obtaining execution information of SQLite, which will not be repeated here.

[0122] Figure 6 FIG. 6 is a structural schematic diagram of a terminal 600 provided by an embodiment of the present application. The terminal 600 can be a smart phone, a tablet computer, an MP3 player, an MP4 player, a notebook computer or a desktop computer. The terminal 600 can also be referred to as a user equipment, a portable terminal, a laptop terminal, a desktop terminal or other names.

[0123] Generally, the terminal 600 includes a processor 601 and a memory 602.

[0124] The processor 601 can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 601 can be implemented in at least one of a hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), a PLA (Programmable Logic Array). The processor 601 can also include a main processor and a coprocessor, the main processor being a processor for processing data in an awake state, also referred to as a CPU (Central Processing Unit), and the coprocessor being a low-power processor for processing data in a standby state. In some embodiments, the processor 601 can be integrated with a GPU (Graphics Processing Unit) that is responsible for rendering and drawing of content to be displayed by the display screen. In some embodiments, the processor 601 can further include an AI (Artificial Intelligence) processor for processing computing operations related to machine learning.

[0125] The memory 602 can include one or more computer-readable storage media that can be non-transitory. The memory 602 can also include a high-speed random access memory, and a nonvolatile memory such as one or more disk storage devices, flash storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction for being executed by the processor 601 to implement the method of obtaining execution information of SQLite provided by various embodiments of the present application.

[0126] In some embodiments, the terminal 600 can also optionally include a peripheral device interface 603 and at least one peripheral device. The processor 601, the memory 602, and the peripheral device interface 603 can be connected through a bus or a signal line. Each peripheral device can be connected to the peripheral device interface 603 through a bus, a signal line, or a circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 604, a touch display screen 605, a camera assembly 606, an audio circuit 607, and a power supply 606.

[0127] The peripheral interface 603 can be used to connect at least one I / O (Input / Output) related peripheral device to the processor 601 and the memory 602. In some embodiments, the processor 601, the memory 602 and the peripheral interface 603 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 601, the memory 602 and the peripheral interface 603 can be implemented on a separate chip or circuit board, and the present embodiments are not limited in this regard.

[0128] The radio frequency circuit 604 is configured to receive and send RF (Radio Frequency) signals, also known as electromagnetic signals. The radio frequency circuit 604 communicates with communication networks and other communication devices through electromagnetic signals. The radio frequency circuit 604 converts electrical signals into electromagnetic signals for transmission, or converts electromagnetic signals received into electrical signals. Optionally, the radio frequency circuit 604 includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a subscriber identity module card, and the like. The radio frequency circuit 604 can communicate with other terminals through at least one wireless communication protocol. The wireless communication protocol includes but is not limited to: a metropolitan area network, various generations of mobile communication networks (2G, 3G, 4G and 5G), a wireless local area network and / or a WiFi (Wireless Fidelity) network. In some embodiments, the radio frequency circuit 604 can also include NFC (Near Field Communication) related circuitry, and the present application is not limited in this regard.

[0129] The display screen 605 is configured to display a UI (User Interface). The UI can include graphics, text, icons, video, and any combination thereof. When the display screen 605 is a touch display screen, the display screen 605 is further configured to capture touch signals on or above the surface of the display screen 605. The touch signals can be input to the processor 601 as control signals for processing. In this case, the display screen 605 can also be configured to provide virtual buttons and / or virtual keyboard, also known as soft buttons and / or soft keyboard. In some embodiments, the display screen 605 can be one, arranged on the front panel of the terminal 600; in other embodiments, the display screen 605 can be at least two, arranged on different surfaces of the terminal 600 or in a folding design; in still other embodiments, the display screen 605 can be a flexible display screen, arranged on a curved surface or a folding surface of the terminal 600. Even, the display screen 605 can also be arranged in an irregular shape other than a rectangle, i.e., a special-shaped screen. The display screen 605 can be made of LCD (Liquid Crystal Display), OLED (Organic Light-Emitting Diode), etc.

[0130] The camera assembly 606 is configured to capture images or videos. Optionally, the camera assembly 606 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is arranged on the front panel of the terminal, and the rear-facing camera is arranged on the back of the terminal. In some embodiments, the rear-facing camera is at least two, which are any one of a main camera, a depth-of-field camera, a wide-angle camera, and a telephoto camera, to realize the background blur function by fusing the main camera and the depth-of-field camera, the panoramic shooting and VR (Virtual Reality) shooting function by fusing the main camera and the wide-angle camera, or other fusion shooting functions. In some embodiments, the camera assembly 606 can further include a flash. The flash can be a single-color-temperature flash or a dual-color-temperature flash. The dual-color-temperature flash refers to the combination of a warm light flash and a cold light flash, which can be used for light compensation under different color temperatures.

[0131] The audio circuit 607 can include a microphone and a speaker. The microphone is used to collect sound waves of the user and the environment, and convert the sound waves into an electrical signal input to the processor 601 for processing, or input to the radio frequency circuit 604 to realize voice communication. For the purpose of stereo sound collection or noise reduction, the microphone can be multiple, respectively arranged at different parts of the terminal 600. The microphone can also be an array microphone or an omnidirectional collection type microphone. The speaker is used to convert the electrical signal from the processor 601 or the radio frequency circuit 604 into sound waves. The speaker can be a conventional diaphragm speaker, or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, not only can the electrical signal be converted into a sound wave that humans can hear, but also can be converted into a sound wave that humans cannot hear for ranging purposes. In some embodiments, the audio circuit 607 can also include a headphone jack.

[0132] The power supply 606 is used to supply power to each component in the terminal 600. The power supply 606 can be alternating current, direct current, disposable battery or rechargeable battery. When the power supply 606 includes a rechargeable battery, the rechargeable battery can support wired charging or wireless charging. The rechargeable battery can also be used to support fast charging technology.

[0133] In some embodiments, the terminal 600 also includes one or more sensors 610. The one or more sensors 610 include, but are not limited to, an acceleration sensor 611, a gyroscope sensor 612, a pressure sensor 613, an optical sensor 615, and a proximity sensor 616.

[0134] The acceleration sensor 611 can detect the acceleration in three coordinate axes of the coordinate system established by the terminal 600. For example, the acceleration sensor 611 can be used to detect the components of the gravitational acceleration in three coordinate axes. The processor 601 can control the touch display 605 to display the user interface in a landscape view or a portrait view according to the gravitational acceleration signal collected by the acceleration sensor 611. The acceleration sensor 611 can also be used for game or user motion data collection.

[0135] The gyroscope sensor 612 can detect the body direction and rotation angle of the terminal 600, and the gyroscope sensor 612 can collect 3D actions of the user on the terminal 600 in cooperation with the acceleration sensor 611. The processor 601 can realize the following functions according to the data collected by the gyroscope sensor 612: motion sensing (such as changing the UI according to the user's tilt operation), image stabilization when shooting, game control, and inertial navigation.

[0136] The pressure sensor 613 can be disposed at the side frame of the terminal 600 and / or the lower layer of the touch display screen 605. When the pressure sensor 613 is disposed at the side frame of the terminal 600, the holding signal of the user to the terminal 600 can be detected, and the left-hand or right-hand recognition or the shortcut operation can be performed by the processor 601 according to the holding signal collected by the pressure sensor 613. When the pressure sensor 613 is disposed at the lower layer of the touch display screen 605, the operable control on the UI interface can be controlled by the processor 601 according to the pressure operation of the user to the touch display screen 605. The operable control includes at least one of the button control, the scroll bar control, the icon control and the menu control.

[0137] The optical sensor 615 is used to collect the ambient light intensity. In one embodiment, the processor 601 can control the display brightness of the touch display screen 605 according to the ambient light intensity collected by the optical sensor 615. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 605 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 605 is decreased. In another embodiment, the processor 601 can also dynamically adjust the shooting parameter of the camera assembly 606 according to the ambient light intensity collected by the optical sensor 615.

[0138] The proximity sensor 616, also called the distance sensor, is usually disposed at the front panel of the terminal 600. The proximity sensor 616 is used to collect the distance between the user and the front of the terminal 600. In one embodiment, when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 gradually decreases, the processor 601 controls the touch display screen 605 to switch from the bright screen state to the off-screen state; when the proximity sensor 616 detects that the distance between the user and the front of the terminal 600 gradually increases, the processor 601 controls the touch display screen 605 to switch from the off-screen state to the bright screen state.

[0139] Those skilled in the art can understand that the structures shown in the above embodiments are not a limitation on the terminal 600, and the terminal 600 can include more or less components than those shown in the figures, or combine certain components, or adopt different component arrangements. Figure 6 Those skilled in the art can understand that the structures shown in the above embodiments are not a limitation on the terminal 600, and the terminal 600 can include more or less components than those shown in the figures, or combine certain components, or adopt different component arrangements.

[0140] Figure 7The server 700 can include one or more processors (Central Processing Units, CPUs) 701 and one or more memories 702. The memory 702 stores at least one program code, which is loaded and executed by the processor 701 to implement the method for obtaining execution information of SQLite according to the embodiments described above. Of course, the server 700 can also have a wired or wireless network interface, a keyboard, an input and output interface, and other components for implementing device functions, which are not described herein.

[0141] In an exemplary embodiment, a computer readable storage medium is also provided, for example, a memory including at least one program code, which can be executed by a processor in an electronic device to complete the method for obtaining execution information of SQLite according to the embodiments described above. For example, the computer readable storage medium can be a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic tape, a floppy disk, an optical data storage device, and the like.

[0142] Those of ordinary skill in the art can understand that all or part of the steps of the above-described embodiments can be completed by hardware, or by a program instructing relevant hardware, which can be stored in a computer readable storage medium. The storage medium mentioned above can be a ROM, a disk or an optical disk, and the like.

[0143] The above is only an optional embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method of obtaining execution information of SQLite, characterized by, The method comprises: in response to a parameter configuration instruction, loading a debugging class of SQLite; obtaining a calling parameter declared by the debugging class; assigning a value to the calling parameter, and the assigned calling parameter being used to indicate calling a performance tuning interface of the SQLite; replacing the performance tuning interface in a runtime library of a device with a target interface; in response to a SQLite connection instruction, obtaining a calling parameter of the performance tuning interface; according to the calling parameter, calling the target interface, calling the performance tuning interface through the target interface, and registering a callback function corresponding to the target interface in the SQLite; in response to a calling instruction of SQLite, according to the callback function registered in the SQLite, calling execution information of the SQLite to the callback function, and obtaining the execution information of the SQLite.

2. The method of claim 1, wherein, The response to the calling instruction of SQLite, according to the callback function registered in the SQLite, calling the execution information of the SQLite to the callback function, and obtaining the execution information of the SQLite, comprises: in response to the calling instruction of SQLite, obtaining the execution information of the SQLite; according to the callback function registered in the SQLite, calling the execution information of the SQLite to the callback function; obtaining the execution information of the SQLite from the callback function.

3. The method of claim 1, wherein, The debugging class is an android.database.sqlite.SQLiteDebug class; the performance tuning interface is a sqlite3_profile interface, and the calling parameter is a DEBUG_SQL_TIME variable; or the performance tuning interface is a sqlite3_trace interface, and the calling parameter is a DEBUG_SQL_STATEMENTS.

4. The method of claim 1, wherein, The method further comprises any one of the following: sending the execution information of the SQLite to a target device; analyzing the execution information of the SQLite, and sending the execution information of the SQLite meeting a target condition to a target device.

5. The method of claim 4, wherein, The execution information of the SQLite comprises at least one structured query language (SQL) statement and an execution duration of each SQL statement; the analysis of the execution information of the SQLite, and the sending of the execution information of the SQLite meeting a target condition to a target device, comprises: obtaining the execution duration of at least one SQL statement in the execution information of the SQLite; in response to the execution duration of any SQL statement being greater than a duration threshold, sending the SQL statement to a target device.

6. An apparatus for acquiring execution information of SQLite, characterized by comprising: The apparatus comprises: a loading module configured to load a debugging class of SQLite in response to a parameter configuration instruction; an obtaining module configured to obtain a calling parameter declared by the debugging class; an assigning module configured to assign a value to the calling parameter, and the assigned calling parameter being used to indicate calling a performance tuning interface of the SQLite; a replacing module configured to replace the performance tuning interface in a runtime library of a device with a target interface; The obtaining module is further configured to obtain a call parameter of the performance tuning interface in response to an SQLite connection instruction. The calling module is configured to call the performance tuning interface of the SQLite according to the call parameter, and register a callback function in the SQLite through the performance tuning interface. The calling module is further configured to call the target interface according to the call parameter, call the performance tuning interface through the target interface, and register a callback function corresponding to the target interface in the SQLite. The calling module is further configured to, in response to a call instruction for the SQLite, call execution information of the SQLite to the callback function according to the callback function registered in the SQLite, and obtain the execution information of the SQLite.

7. The apparatus of claim 6, wherein, The calling module is configured to: obtain execution information of the SQLite in response to a call instruction for the SQLite; call the execution information of the SQLite to the callback function according to the callback function registered in the SQLite; and obtain the execution information of the SQLite from the callback function.

8. The apparatus of claim 6, wherein, The debugging class is an android.database.sqlite.SQLiteDebug class. The performance tuning interface is a sqlite3_profile interface, and the call parameter is a DEBUG_SQL_TIME variable; or the performance tuning interface is a sqlite3_trace interface, and the call parameter is a DEBUG_SQL_STATEMENTS.

9. The apparatus of claim 6, wherein, The apparatus further includes a sending module configured to perform any of the following: send the execution information of the SQLite to a target device; and analyze the execution information of the SQLite, and send execution information of the SQLite that meets a target condition to a target device.

10. The apparatus of claim 9, wherein, The execution information of the SQLite includes at least one structured query language (SQL) statement and an execution duration of each SQL statement. The sending module is configured to: obtain the execution duration of at least one SQL statement in the execution information of the SQLite; and in response to the execution duration of any SQL statement being greater than a duration threshold, send the SQL statement to a target device.

11. An electronic device, comprising: The electronic device includes one or more processors and one or more memories, and the one or more memories store at least one piece of program code, which is loaded and executed by the one or more processors to implement operations performed by the method for obtaining execution information of SQLite according to any one of claims 1 to 5.

12. A storage medium, characterized by The storage medium stores at least one piece of program code, which is loaded and executed by the processor to implement operations performed by the method for obtaining execution information of SQLite according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Tile map data and service updating method and system based on parallel computing mode

    CN104794217A

  • Data storage method and device

    CN110727739A