Anomalous query identification using query clustering
Abstract
Techniques are disclosed relating to managing database queries. In some embodiments, a server system receives a query from a computer system and determines a set of aspects for the query, including at least a number of columns specified in the query and a computational cost of executing the query. The system generates a query vector based on the set of aspects determined for the query. The system then compares the query vector with a plurality of clusters, ones of the plurality of clusters comprising two or more previously generates query vectors generated based on aspects of queries previously received by the server system. Based on the comparing, specifically a distance between the query vector and the plurality of clusters of previously generated query vectors, the system classifies the query. Based on a classification of the query determined during the classifying, the system manages the query.
Interactive Citation Constellation Global Citation Ranking
Interactive SVG Citation Constellation renders in Rust/WebAssembly. Prior art cited: 6 · Forward citations: 0.
Claims (8 — 2 Independent, 6 Dependent)
- Claim 1Independent Claim
A method, comprising: receiving, by a server system, a query; determining, by the server system, one or more aspects for the query, including at least a computational cost of executing the query; generating, by the server system based on the one or more aspects for the query, a query vector; comparing, by the server system, the query vector with a plurality of clusters, ones of the plurality of clusters comprising two or more previously generated query vectors generated based on aspects of queries previously received by the server system; classifying, by the server system based on the comparing, the query, wherein the classifying is based on a distance between the query vector and the plurality of clusters of previously generated query vectors; and managing, by the server system, the query based on a classification of the query determined during the classifying.
- Claim 2Depends on #1
The method of claim 1, further comprising, prior to receiving the query: generating, by the server system for a plurality of previously received queries, a plurality of query vectors; and performing, by the server system, a clustering operation on the plurality of query vectors, wherein output of the clustering operation is the plurality of clusters of two or more of the plurality of query vectors.
- Claim 3Depends on #2
The method of claim 2, further comprising: selecting, by the server system, query vectors of the plurality of query vectors that are located at a center of ones of the plurality of clusters to be centroids of their respective clusters.
- Claim 4Depends on #1
The method of claim 1, wherein the distance is determined by: measuring a Euclidean distance between the query vector and centroids of respective clusters of the plurality of clusters of previously generated query vectors.
- Claim 5Depends on #1
The method of claim 1, wherein the classifying includes assigning an anomalous classification to the query based on the query vector having a distance from the plurality of clusters that is greater than a distance threshold requirement.
- Claim 6Depends on #1
The method of claim 1, wherein managing the query based on the classification of the query includes: transmitting, by the server system to a computer system from which the query was received, an alert for the query, wherein the alert specifies the classification of the query and one or more preventative actions for the query.
- Claim 7Depends on #1
The method of claim 1, wherein determining the one or more aspects for the query further includes determining one or more aspects of the following aspects: a number of columns specified in the query, a query type for the query, one or more table object identifiers referenced in the query, and a number of tables specified in the query.
- Claim 8Independent Claim
A non-transitory computer-readable medium having instructions stored thereon that are capable of causing a computing device to implement operations comprising: receiving a query; determining one or more aspects for the query, including at least a number of modifications specified in the query; generating, based on the one or more aspects for the query, a query vector; comparing the query vector with a plurality of clusters, ones of the plurality of clusters comprising two or more of previously generated query vectors generated based on aspects of queries previously received by the computing device; classifying, based on the comparing, the query, wherein the classifying is based on a distance between the query vector and the plurality of clusters of previously generated query vectors; and managing the query based on a classification of the query determined during the classifying.
Technical Overview & Description
The present application is a continuation of U.S. application Ser. No. 18/418,991, filed Jan. 22, 2024, the disclosure of which are incorporated by reference herein in their entirety. BACKGROUND Technical Field This disclosure relates generally to database systems, and, more specifically, to database optimizations. Description of the Related Art When a query is submitted to a database, it may express what the result of a query should be. This result is then ingested by the system operating the database in order to determine one or more ways to execute the query (which may be done using several approaches). For example, a query requesting a join of tables A, B, and C may be executed as 1) a join of A and B followed by a join of the result and C or 2) a join of B and C followed by a join of A and the result. Modern relational database systems typically employ a query optimizer that receives a parsed query and evaluates different query execution plans to determine a plan for executing a query on the database. Such systems, however, often receive an inordinate number of queries each second, minute, day, etc., making it difficult or time-consuming for the database system to optimize the queries. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a block diagram illustrating a server system configured to classify queries according to a plurality of query aspects, according to some embodiments. FIG. 2 is a block diagram illustrating example vector and cluster modules, according to some embodiments. FIG. 3 is a diagram illustrating example queries, a query vector format, and example query vectors, according to some embodiments. FIG. 4 is a diagram illustrating an example cluster and example distance measuring between a query vector and two different clusters, according to some embodiments. FIG. 5 is a block diagram illustrating an example classification module, according to some embodiments. FIG. 6 is a flow diagram illustrating a method for classifying queries, according to some
Cited By — Indexed Forward Citations (0 of 0 total)
No indexed citing patents in this generation yet. Ingest USPTO/PatentsView bulk citation tables via patents-ingest to expand the local forward citation graph.
References Cited — Backward Prior Art (6)
| Patent | Title | Year | Citations |
|---|
Non-Patent Literature (1)
- International Search Report and Written Opinion in PCT Appl. No. PCT/US2024/060941 mailed Mar. 25, 2025, 13 pages.