Splitting a time-range query into multiple sub-queries for serial execution
Techniques for splitting a time-range query into sub-queries for serial execution are provided. In one embodiment, a user query is received requesting items within a time range from a database. The time range is divided into a plurality of time periods within the time range. Sub-queries defining respective time periods of the plurality of time periods are generated from the user query, and a first sub-query is executed. The first sub-query defines a first time period of the plurality of time periods, where the first time period is a most-recent time period or a least-recent time period among the plurality of time periods. If it is determined that a number of items obtained from executing the first sub-query is greater than or equal to a predetermined result target, then the items obtained from executing the first sub-query are provided and subsequent sub-queries are not executed.
1. A method for splitting a time-range query into sub-queries for serial execution, the method comprising:
at a management plane of a distributed-computing system:
receiving a user query requesting items stored by a database platform implemented on a data plane of the distributed-computing system, the user query specifying a time range;
dividing the time range into a plurality of time periods within the time range, wherein each time period of the plurality of time periods corresponds to a respective number of items in the database platform, and wherein the plurality of time periods include:
a first time period corresponding to a first number of items,
a second time period corresponding to a second number of items larger than the first number of items, and
a third time period corresponding to a third number of items larger than the first and second numbers of items;
generating a plurality of sub-queries from the user query, each sub-query of the plurality of sub-queries defining a respective time period of the plurality of time periods;
executing a first sub-query of the plurality of sub-queries to obtain items from the database platform, wherein the first sub-query defines the first time period of the plurality of time periods, wherein the first time period corresponds to a smaller number of items than the respective numbers of items corresponding to other time periods in the plurality of time periods, and wherein the first time period is a most-recent time period or a least-recent time period among the plurality of time periods;
in accordance with a determination that a number of items obtained from executing the first sub-query is greater than or equal to a predetermined result target:
providing the items obtained from executing the first sub-query; and
forgoing executing subsequent sub-queries of the plurality of sub-queries.
2. The method of claim 1 , further comprising:
in accordance with a determination that the number of items obtained from executing the first sub-query is not greater than or equal to a predetermined result target:
executing one or more subsequent sub-queries of the plurality of sub-queries until a number of items greater than or equal to the predetermined result target are obtained; and
providing the items obtained from executing the first sub-query and the one or more subsequent sub-queries.
3. The method of claim 2 , wherein a second sub-query in the one or more subsequent queries defines the second time period of the plurality of time periods, and wherein the second time period is a time period immediately prior to the most-recent time period or a time period immediately following the least-recent time period among the plurality of time periods.
4. The method of claim 1 , further comprising:
displaying a predetermined number of the items obtained from executing the first sub-query, wherein the predetermined number corresponds to the predetermined result target.
5. The method of claim 1 , further comprising:
sorting the items obtained from executing the first sub-query into chronological or reverse chronological order based on a timestamp associated with each item; and
displaying a predetermined number of the sorted items in chronological or reverse chronological order, wherein the predetermined number corresponds to the predetermined result target.
6. The method of claim 2 , further comprising:
sorting the items obtained from executing the first sub-query and the one or more subsequent sub-queries into chronological or reverse chronological order based on a timestamp associated with each item; and
displaying a predetermined number of the sorted items in chronological or reverse chronological order, wherein the predetermined number corresponds to the predetermined result target.
7. The method of claim 1 , wherein the predetermined result target corresponds to a predetermined maximum number of items for display on a page of results.
8. The method of claim 7 , further comprising:
receiving a request for a subsequent page of results;
executing one or more subsequent sub-queries of the plurality of sub-queries until a number of items greater than or equal to the predetermined result target are obtained; and
providing the items obtained from executing the one or more subsequent sub-queries.
9. The method of claim 1 , further comprising:
storing an item timestamp corresponding to a most-recent or least-recent timestamped item obtained from executing the first sub-query, wherein the stored item timestamp defines a second time period for a second sub-query of the plurality of sub-queries.
10. The method of claim 9 , further comprising:
receiving a request to provide additional items corresponding to the user query;
in response to receiving the request, executing the second sub-query of the plurality of sub-queries to obtain additional items from the database platform; and
providing the additional items obtained from executing the second sub-query.
11. The method of claim 1 , wherein the items stored by the database platform include log event records generated by an information processing system.
12. The method of claim 1 , wherein each item stored by the database platform corresponds to a record generated by an information processing system separate from the distributed-computing system, wherein each item is associated with a timestamp assigned by the information processing system.
13. A distributed-computing system for splitting a time-range query into sub-queries for serial execution, comprising
one or more processors; and
memory storing one or more programs configured to be executed by the one or more processors, the one or more programs including instructions for:
at a management plane of a distributed-computing system:
accessing a received user query requesting items stored by a database platform implemented on a data plane of the distributed-computing system, the user query specifying a time range;
dividing the time range into a plurality of time periods within the time range, wherein each time period of the plurality of time periods corresponds to a respective number of items in the database platform, and wherein the plurality of time periods include:
a first time period corresponding to a first number of items,
a second time period corresponding to a second number of items larger than the first number of items, and
a third time period corresponding to a third number of items larger than the first and second numbers of items;
generating a plurality of sub-queries from the user query, each sub-query of the plurality of sub-queries defining a respective time period of the plurality of time periods;
executing a first sub-query of the plurality of sub-queries to obtain items from the database platform, wherein the first sub-query defines the first time period of the plurality of time periods, wherein the first time period corresponds to a smaller number of items than the respective numbers of items corresponding to other time periods in the plurality of time periods, and wherein the first time period is a most-recent time period or a least-recent time period among the plurality of time periods;
in accordance with a determination that a number of items obtained from executing the first sub-query is greater than or equal to a predetermined result target:
providing the items obtained from executing the first sub-query; and
forgoing executing subsequent sub-queries of the plurality of sub-queries.
14. The distributed-computing system of claim 13 , wherein the one or more programs further include instructions for:
in accordance with a determination that the number of items obtained from executing the first sub-query is not greater than or equal to a predetermined result target:
executing one or more subsequent sub-queries of the plurality of sub-queries until a number of items greater than or equal to the predetermined result target are obtained; and
providing the items obtained from executing the first sub-query and the one or more subsequent sub-queries.
15. The distributed-computing system of claim 13 , wherein the one or more programs further include instructions for:
displaying a predetermined number of the items obtained from executing the first sub-query, wherein the predetermined number corresponds to the predetermined result target.
16. The distributed-computing system of claim 13 , wherein the one or more programs further include instructions for:
sorting the items obtained from executing the first sub-query into chronological or reverse chronological order based on a timestamp associated with each item; and
displaying a predetermined number of the sorted items in chronological or reverse chronological order, wherein the predetermined number corresponds to the predetermined result target.
17. A non-transitory computer-readable storage medium storing one or more programs configured to be executed by one or more processors, the one or more programs including instructions for:
at a management plane of a distributed-computing system:
accessing a received user query requesting items stored by a database platform implemented on a data plane of the distributed-computing system, the user query specifying a time range;
dividing the time range into a plurality of time periods within the time range, wherein each time period of the plurality of time periods corresponds to a respective number of items in the database platform, and wherein the plurality of time periods include:
a first time period corresponding to a first number of items,
a second time period corresponding to a second number of items larger than the first number of items, and
a third time period corresponding to a third number of items larger than the first and second numbers of items;
generating a plurality of sub-queries from the user query, each sub-query of the plurality of sub-queries defining a respective time period of the plurality of time periods;
executing a first sub-query of the plurality of sub-queries to obtain items from the database platform, wherein the first sub-query defines the first time period of the plurality of time periods, wherein the first time period corresponds to a smaller number of items than the respective numbers of items corresponding to other time periods in the plurality of time periods, and wherein the first time period is a most-recent time period or a least-recent time period among the plurality of time periods;
in accordance with a determination that a number of items obtained from executing the first sub-query is greater than or equal to a predetermined result target:
providing the items obtained from executing the first sub-query; and
forgoing executing subsequent sub-queries of the plurality of sub-queries.
18. The non-transitory computer-readable storage medium of claim 17 , wherein the one or more programs further include instructions for:
in accordance with a determination that the number of items obtained from executing the first sub-query is not greater than or equal to a predetermined result target:
executing one or more subsequent sub-queries of the plurality of sub-queries until a number of items greater than or equal to the predetermined result target are obtained; and
providing the items obtained from executing the first sub-query and the one or more subsequent sub-queries.
19. The non-transitory computer-readable storage medium of claim 17 , wherein the one or more programs further include instructions for:
displaying a predetermined number of the items obtained from executing the first sub-query, wherein the predetermined number corresponds to the predetermined result target.
20. The non-transitory computer-readable storage medium of claim 17 , wherein the one or more programs further include instructions for:
sorting the items obtained from executing the first sub-query into chronological or reverse chronological order based on a timestamp associated with each item; and
displaying a predetermined number of the sorted items in chronological or reverse chronological order, wherein the predetermined number corresponds to the predetermined result target.