IP Library Granted Patent US 8,019,750
Granted Patent B2
US 8,019,750 · App. 11/327,945 · Granted Sep 13, 2011

System and method for automatically generating database queries

Assignee: Computer Associates Think, Inc.
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 8,019,750
App. No.
11/327,945
Granted
Sep 13, 2011
Kind
B2
Abstract

A method of tuning a database query includes selecting a database query, parsing the selected database query to determine relationships between portions of the selected database query, selecting an optimization mode from a plurality of available optimization modes, tuning the selected database query by modifying, at least one portion of the selected database query based on the determined relationships and the selected optimization mode and displaying the modified database query.

Claims (81)

1. A method of tuning a database query, comprising:

allowing a user to select a query of a database;

parsing the selected database query to determine that the database query includes a first operator;

selecting an optimization mode from a plurality of available optimization modes, wherein:

a first optimization mode is automatically selected if one or more statistics exist for a table identified by the database query, and

a second optimization mode is selected if one or more statistics do not exist for the table identified by the database query;

tuning automatically the selected database query based on the structure of the database and the selected optimization mode; and

displaying the tuned database query, and

wherein automatically tuning the selected database query comprises automatically rewriting the selected database query by converting the first operator to a second operator.

2. The method as recited in claim 1 ,

wherein the parsing determines tokens within the database query, tokens being words separated by delimiters.

3. The method as recited in claim 1 , wherein the plurality of available optimization modes include Cost based and Rule based modes.

4. The method as recited in claim 3 , wherein the Cost based modes include First_Rows mode and All_Rows mode.

5. The method as recited in claim 1 , further comprising determining a cost associated with using the tuned database query.

6. The method as recited in claim 5 , further comprising comparing a cost associated with using the selected database query to the cost associated with using the tuned database query.

7. The method as recited in claim 1 , further comprising parsing the selected database query to determine whether the database query includes at least one subquery joined by at least one of a NOT EXISTS, a NOT IN and an ALL clause.

8. The method as recited in claim 7 , further comprising prompting a user to select preferences to be used during tuning based on whether the database query includes at least one of a NOT EXISTS, a NOT IN and an ALL clause.

9. The method of claim 1 , wherein tuning automatically the selected database query comprises changing a join order of the selected database query or moving a subquery within the selected database query.

10. The method of claim 1 , further comprising displaying a diagram of each subquery included in the selected database query.

11. The method of claim 1 , further comprising displaying a primary key for each table referenced in the selected database query.

12. The method as recited in claim 8 , wherein the preferences include rewrite preferences for enabling a user to select at least one of a conversion of NOT EXISTS operators to a NOT IN operator and conversion of the selected database query to an outer join.

13. The method as recited in claim 8 , wherein the preferences include rewrite preferences for enabling a user to select to convert subqueries joined by an ALL operator to a join or outer-join.

14. The method as recited in claim 8 , wherein the preferences include rewrite preferences for enabling a user to select whether to use at least one of a NOT EXISTS operator and an outer-join to convert subqueries joined by a NOT In operator.

15. A computer storage medium including computer executable code for tuning a database query, comprising:

computer executable code for allowing a user to select a query of a database;

computer executable code for parsing the selected database query to determine that the database query includes a first operator;

computer executable code for selecting an optimization mode from a plurality of available optimization modes, wherein:

a first optimization mode is automatically selected if one or more statistics exist for a table identified by the database query, and

a second optimization mode is selected if one or more statistics do not exist for the table identified by the database query;

computer executable code for automatically tuning the selected database query based on the structure of the database and the selected optimization mode; and

computer executable code for displaying the tuned database query, and

wherein the computer executable code for automatically tuning the selected database query comprises computer executable code for automatically rewriting the selected database query by converting the first operator to a second operator.

16. The computer storage medium as recited in claim 15 , wherein the parsing determines tokens within the database query, tokens being words separated by delimiters.

17. The computer storage medium as recited in claim 15 , wherein the plurality of available optimization modes include Cost based and Rule based modes.

18. The computer storage medium as recited in claim 17 , wherein the Cost based modes include First_Rows mode and All_Rows mode.

19. The computer storage-medium as recited in claim 15 , further comprising code for determining a cost associated with using the tuned database query.

20. The computer storage medium as recited in claim 19 , further comprising code for comparing a cost associated with using the selected database query to the cost associated with using the tuned database query.

21. The computer storage medium as recited in claim 15 , further comprising code for parsing the selected database query to determine whether the database query includes at least one subquery joined by at least one of a NOT EXISTS, a NOT IN and an ALL clause.

22. The computer storage medium as recited in claim 21 , further comprising code for prompting a user to select preferences to be used during tuning based on whether the database query includes at least one of a NOT EXISTS, a NOT IN and an ALL clause.

23. The computer storage medium as recited in claim 22 , wherein the preferences include rewrite preferences for enabling a user to select at least one of a conversion of NOT EXISTS operators to a NOT IN operator and conversion of the selected database query to an outer join.

24. The computer storage medium as recited in claim 22 , wherein the preferences include rewrite preferences for enabling a user to select to convert subqueries joined by an ALL operator to a join or outer-join.

25. The computer storage medium as recited in claim 22 , wherein the preferences include rewrite preferences for enabling a user to select whether to use at least one of a NOT EXISTS operator and an outer-join to convert subqueries joined by a NOT In operator.

26. A programmed computer system for tuning a database query, comprising:

a display for displaying at least one of a plurality of database queries of a database to a user;

a user input allowing the user to select a database query from among the displayed database queries; and

a processor for parsing the selected database query to determine that the database query includes a first operator and for automatically tuning the selected database query based on the structure of the database, the tuned database query being displayed to the user via the display, wherein automatically tuning the selected database query comprises:

automatically selecting a first optimization mode if one or more statistics exist for a table identified by the database query, and

selecting a second optimization mode is selected if one or more statistics do not exist for the table identified by the database query, and

wherein automatically tuning the selected database query comprises automatically rewriting the selected database query by converting the first operator to a second operator.

27. The system as recited in claim 26 , wherein the parsing determines tokens within the database query, tokens being words separated by delimiters.

28. The system as recited in claim 26 , wherein the plurality of available optimization modes include Cost based and Rule based modes.

29. The system as recited in claim 28 , wherein the Cost based modes include First_Rows mode and All_Rows mode.

30. The system as recited in claim 26 , wherein the processor determines a cost associated with using the tuned database query.

31. The system as recited in claim 30 , wherein the processor compares a cost associated with using the selected database query to the cost associated with using the tuned database query.

32. The system as recited in claim 26 , wherein the processor parses the selected database query to determine whether the database query includes at least one subquery joined by at least one of a NOT EXISTS, a NOT IN and an ALL clause.

33. The system as recited in claim 32 , wherein the processor prompts the user to select preferences to be used during tuning based on whether the database query includes at least one of a NOT EXISTS, a NOT IN and an ALL clause.

34. The system as recited in claim 33 , wherein the preferences include rewrite preferences for enabling a user to select at least one of a conversion of NOT EXISTS operators to a NOT IN operator and conversion of the selected database query to an outer join.

35. The system as recited in claim 33 , wherein the preferences include rewrite preferences for enabling a user to select to convert subqueries joined by an ALL operator to a join or outer-join.

36. The system as recited in claim 33 , wherein the preferences include rewrite preferences for enabling a user to select whether to use at least one of a NOT EXISTS operator and an outer-join to convert subqueries joined by a NOT In operator.

37. A method of tuning a database query, comprising:

allowing a user to select a query of a database;

parsing the selected database query to determine that the database query includes a first operator;

selecting an optimization mode from a plurality of available optimization modes;

tuning automatically the selected database query based on the structure of the database and the selected optimization mode; and

displaying the tuned database query,

wherein automatically tuning the selected database query comprises automatically rewriting the selected database query by converting the first operator to a second operator, and

wherein selecting the optimization mode from the plurality of available optimization modes comprises:

determining whether one or more statistics exist for a table identified by the query;

automatically selecting a first optimization mode if the one or more statistics exist for the table; and

automatically selecting a second optimization mode if the one or more statistics do not exist for the table.

38. A method of tuning a database query, comprising:

allowing a user to select a query of a database;

parsing the selected database query to determine that the database query includes a first operator;

selecting an optimization mode from a plurality of available optimization modes;

tuning automatically the selected database query based on the structure of the database and the selected optimization mode; and

displaying the tuned database query,

wherein automatically tuning the selected database query comprises automatically rewriting the selected database query by converting the first operator to a second operator, and

wherein selecting the optimization mode from the plurality of available optimization modes comprises:

determining whether one or more statistics exist for a table identified by the query;

automatically selecting a first optimization mode if the one or more statistics exist for the table; and

receiving user preferences for selecting a second optimization mode if the one or more statistics do not exist for the table.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 15, 2006
From: VINCENT, JOHN K.; WERLING, THOMAS K.; LAU, JOYCE H.
To: COMPUTER ASSOCIATES THINK, INC.
Reel/Frame 018261/0860 →
Continuity (8)
Continuation 11129867 · May 16, 2005
Continuation 10913998 · Aug 6, 2004
Continuation 10626426 · Jul 24, 2003
Continuation 10288659 · Nov 5, 2002
Continuation 10087890 · Feb 28, 2002
Continuation 09865276 · May 25, 2001
Provisional Application 60207379 · May 26, 2000
Related Publication 20070038618A1 · Feb 15, 2007