IP Library Granted Patent US 12,632,452
Granted Patent B2
US 12,632,452 · App. 19/018,006 · Granted May 19, 2026

Anomalous query identification using query clustering

Inventors: Anup Ghatage (Fremont, CA); Colm McHugh (Dublin, IE)
Assignee: Salesforce, Inc.
G06F16/24545G06F16/285
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,632,452
App. No.
19/018,006
Granted
May 19, 2026
Kind
B2
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.

Claims (56)

1 . 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.

2 . 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.

3 . 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.

4 . 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.

5 . 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.

6 . 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.

7 . 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.

8 . 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.

9 . The non-transitory computer-readable medium of claim 8 , wherein the operations further comprise, prior to receiving the query:

generating, for a plurality of previously received queries, a plurality of query vectors, wherein generating the plurality of query vectors includes identifying two or more aspects for respective queries; and

performing 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 representing the plurality of previously received queries; and

assigning query encodings located at a center of ones of the plurality of clusters as centroids of their respective cluster.

10 . The non-transitory computer-readable medium of claim 8 , 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 computational cost of executing 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.

11 . The non-transitory computer-readable medium of claim 8 , wherein the managing includes:

transmitting, to a computer system from which the query was received, a request for one or more authentication factors.

12 . The non-transitory computer-readable medium of claim 8 , wherein the managing includes:

escalating one or more preventative actions based on the distance, wherein the escalating includes performing more restrictive preventative actions for the query vector that is a greater distance from one or more of the plurality of clusters than preventative actions performed for another query vector that is a smaller distance from one or more of the plurality of clusters.

13 . The non-transitory computer-readable medium of claim 8 , wherein the distance between the query vector and the plurality of clusters of previously generated query vectors is determined by:

measuring, using cosine similarity, a distance between the query vector and centroids of respective clusters of the plurality of clusters of previously generated query vectors.

14 . The non-transitory computer-readable medium of claim 8 , wherein the managing includes:

transmitting, to a computer system from which the query was received, a notification requesting alteration of the query, wherein the notification specifies one or more deficiencies of the query corresponding to the requested alteration.

15 . A system, comprising:

at least one processor; and

a memory having instructions stored thereon that are executable by the at least one processor to cause the system to:

receive a query;

determine one or more aspects for the query, including at least one or more table object identifiers referenced in the query;

generate, based on the one or more aspects for the query, a query vector;

compare 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 system;

classify, 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

manage the query based on a classification of the query determined during the classifying.

16 . The system of claim 15 , wherein the instructions are further executable by the at least one processor to cause the system to, prior to receiving the query:

generate, for a plurality of previously received queries, a plurality of query vectors, wherein generating the plurality of query vectors includes identifying two or more aspects for respective queries.

17 . The system of claim 16 , wherein the instructions are further executable by the at least one processor to cause the system to, prior to receiving the query:

perform 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 representing the plurality of previously received queries.

18 . The system of claim 16 , wherein the instructions are further executable by the at least one processor to cause the system to:

assign query encodings located at a center of ones of the plurality of clusters as centroids of their respective cluster.

19 . The system of claim 15 , wherein the classifying includes:

assigning, based on comparing the distance between the generated query vector and the plurality of clusters with a distance threshold, the classification of the query to the query vector.

20 . The system of claim 15 , 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 computational cost of executing the query, a query type for the query, and a number of tables specified in the query.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 13, 2025
From: GHATAGE, ANUP; MCHUGH, COLM
To: SALESFORCE, INC.
Reel/Frame 069835/0156 →
Continuity (2)
Continuation 18418991 · Jan 22, 2024
Related Publication 20250238422A1 · Jul 24, 2025
References Cited (7)
US 11509721B2 · Ghatage et al. · 2022 [cited by applicant]
US 20120209847A1 · Rangan · 2012 [cited by applicant]
US 20170351951A1 · Santos et al. · 2017 [cited by applicant]
US 20210056108A1 · Shmueli et al. · 2021 [cited by applicant]
US 20230205760A1 · McHugh et al. · 2023 [cited by applicant]
JP 2011034417A · 2011 [cited by applicant]
International Search Report and Written Opinion in PCT Appl. No. PCT/US2024/060941 mailed Mar. 25, 2025, 13 pages. [cited by applicant]