IP Library Granted Patent US 7,099,863
Granted Patent B2
US 7,099,863 · App. 10/425,164 · Granted Aug 29, 2006

System and method for caching database query statements

Assignee: International Business Machines Corporation
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 7,099,863
App. No.
10/425,164
Granted
Aug 29, 2006
Kind
B2
Abstract

In a database system that supports object name overloading, database query statements are compiled and cached as data structures so that object level privileges are correctly resolved. Database query statements stored in the cached data structures are utilized when appropriate and a new compilation is performed when an incorrect resolution would result. The data structures are stored in a predefined order to ensure that a deterministic search of the cache is efficiently performed.

Claims (84)

1. A method of directing a database management system to cache a database query statement into a memory cache, the database query statement belonging to a user with a privilege to selected database access routines, the method comprising:

determining a best available match for each routine object reference in the database query statement, by selecting a matching routine from among the routines, which considered as a match;

adding the best available match to a list of better match routines if the user does not have privilege the privilege to access the best available match;

adding the best available match to a list of resolved-to routines if the user has the privilege to access the best available match; and

storing the list of better match objects and the list of resolved-to objects as part of a data structure in the memory cache.

2. The method as claimed in claim 1 , wherein adding the best available match to the list of better match objects comprises:

searching the list of better match objects for the routine reference; and

adding an entry corresponding to the routine reference to the list of better match objects if the routine reference is not found in the list of better match objects.

3. The method as claimed in claim 1 , wherein adding the best available match to the list of resolved-to routines comprises:

searching the list of resolved-to routines for the routine reference; and

adding an entry corresponding to the routine reference to the list of resolved-to routines if the routine reference is not found in the list of resolved-to routines.

4. The method as claimed in claim 1 , further comprising eliminating each routine reference selected as a better match from further consideration as a match.

5. The method as claimed in claim 1 , further comprising expressing the database query statement in a dynamic structured query language; and

wherein the database query comprises overloaded object types.

6. The method as claimed in claim 1 , further comprising:

searching the data structure for a previously compiled database query statement having a statement text and a base environment matching the statement text and the base environment being associated with the database query; and

creating a new environment to ensure that a new compilation of the database query takes place if a match is not found.

7. The method as claimed in claim 6 , further comprising, if the matching statement text and matching base environment are found:

examining information in the data structure to determine whether an associated routine environment is a match for the current user; and

using the compiled database query statement if there is a match.

8. The method as claimed in claim 7 , further comprising, if the user has a privilege to access a better match routine in the routine environment:

creating a new environment to ensure that a new compilation takes place; and

setting a predetermined variable to a first value to control a position of a new data structure in the memory cache.

9. The method as claimed in claim 8 , further comprising, if the user does not have the privilege to access the better match routine in the routine environment:

searching the data structures in the memory cache for another matching statement text and another matching base environment;

reexamining information in the data structure;

creating a new environment to ensure that a new compilation takes place if another matching base environment is not found; and

setting the predetermined variable to a second value to control the position of the new data structure in the memory cache.

10. The method as claimed in claim 9 , wherein if the matching statement text and the matching base environment are not found and the new compilation is successful, storing the new data structure in the memory cache.

11. The method as claimed in claim 10 , wherein if the predetermined variable is set to the first value and the new compilation is successful, storing the new data structure in the memory cache before the data structure with the matching statement text and the matching base environment.

12. The method as claimed in claim 11 , wherein if the predetermined variable is set to the second value and the new compilation is successful, storing the new data structure in the memory cache after the data structure with the matching statement text and the matching base environment.

13. A computer program product having a plurality of executable instruction codes that are stored on a computer usable medium for directing a database management system to cache a database query statement into a memory cache, the database query statement belonging to a user with a privilege to selected database access routines, the computer program product comprising:

a first set of instruction codes for determining a best available match for each routine object reference in the database query statement, by selecting a matching routine from among the routines, which is considered as a match;

a second set of instruction codes for adding the best available match to a list of better match routines if the user does not have privilege the privilege to access the best available match;

a third set of instruction codes for adding the best available match to a list of resolved-to routines if the user has the privilege to access the best available match; and

a fourth set of instruction codes for storing the list of better match objects and the list of resolved-to objects as part of a data structure in the memory cache.

14. The computer program product as claimed in claim 13 , wherein the second set of instruction codes comprises:

instruction codes for searching the list of better match objects for the routine reference; and

instruction codes for adding an entry corresponding to the routine reference to the list of better match objects if the routine reference is not found in the list of better match objects.

15. The computer program product as claimed in claim 13 , wherein the second set of instruction codes comprises:

instruction codes for searching the list of resolved-to routines for the routine reference; and

instruction codes for adding an entry corresponding to the routine reference to the list of resolved-to routines if the routine reference is not found in the list of resolved-to routines.

16. The computer program product as claimed in claim 13 , further comprising a fifth set of instruction codes for eliminating each routine reference selected as a better match from further consideration as a match.

17. The computer program product as claimed in claim 13 , further comprising a sixth set of instruction codes for expressing the database query statement in a dynamic structured query language; and

wherein the database query comprises overloaded object types.

18. The computer program product as claimed in claim 13 , further comprising:

a seventh set of instruction codes for searching the data structure for a previously compiled database query statement having a statement text and a base environment matching the statement text and the base environment being associated with the database query; and

an eight set of instruction codes for creating a new environment to ensure that a new compilation of the database query takes place if a match is not found.

19. The computer program product as claimed in claim 18 , further comprising, if the matching statement text and matching base environment are found, a ninth set of instruction codes examines information in the data structure to determine whether an associated routine environment is a match for the current user, and uses the compiled database query statement if there is a match.

20. The computer program product as claimed in claim 19 , further comprising, if the user has a privilege to access a better match routine in the routine environment, a tenth set of instruction codes creates a new environment to ensure that a new compilation takes place, and sets a predetermined variable to a first value to control a position of a new data structure in the memory cache.

21. The computer program product as claimed in claim 20 , further comprising, an eleventh set of instruction codes, which, if the user does not have the privilege to access the better match routine in the routine environment:

searches the data structures in the memory cache for another matching statement text and another matching base environment;

reexamines information in the data structure;

creates a new environment to ensure that a new compilation takes place if another matching base environment is not found; and

sets the predetermined variable to a second value to control the position of the new data structure in the memory cache.

22. The computer program product as claimed in claim 21 , wherein if the matching statement text and the matching base environment are not found and the new compilation is successful, the fourth set of instruction codes stores the new data structure in the memory cache.

23. The computer program product as claimed in claim 22 , wherein if the predetermined variable is set to the first value and the new compilation is successful, the fourth set of instruction codes further stores the new data structure in the memory cache before the data structure with the matching statement text and the matching base environment.

24. The computer program product as claimed in claim 23 , wherein if the predetermined variable is set to the second value and the new compilation is successful, the fourth set of instruction codes stores the new data structure in the memory cache after the data structure with the matching statement text and the matching base environment.

25. A database management system for caching a database query statement into a memory cache, the database query statement belonging to a user with privilege to selected database access routines, the system comprising:

means for determining a best available match for each routine object reference in the database query statement, by selecting a matching routine from among the routines, which is considered as a match;

means for adding the best available match to a list of better match routines if the user does not have privilege the privilege to access the best available match;

means for adding the best available match to a list of resolved-to routines if the user has the privilege to access the best available match; and

means for storing the list of better match objects and the list of resolved-to objects as part of a data structure in the memory cache.

26. The system as claimed in claim 25 , wherein the means for adding the best available match to the list of better match routines comprises:

means for searching the list of better match objects for the routine reference; and means for adding an entry corresponding to the routine reference to the list of better match objects if the routine reference is not found in the list of better match objects.

27. The system as claimed in claim 25 , wherein the means for adding the best available match to the list of better match routines comprises:

means for searching the list of resolved-to routines for the routine reference; and

means for adding an entry corresponding to the routine reference to the list of resolved-to routines if the routine reference is not found in the list of resolved-to routines.

28. The system as claimed in claim 25 , further comprising means for eliminating each routine reference selected as a better match from further consideration as a match.

29. The system as claimed in claim 25 , further comprising means for expressing the database query statement in a dynamic structured query language; and

wherein the database query comprises overloaded object types.

30. The system as claimed in claim 25 , further comprising:

means for searching the data structure for a previously compiled database query statement having a statement text and a base environment matching the statement text and the base environment being associated with the database query; and

means for creating a new environment to ensure that a new compilation of the database query takes place if a match is not found.

31. The system as claimed in claim 30 , further comprising, if the matching statement text and matching base environment are found, means for examining information in the data structure to determine whether an associated routine environment is a match for the current user, and for using the compiled database query statement if there is a match.

32. The system as claimed in claim 31 , further comprising, if the user has a privilege to access a better match routine in the routine environment, means for creating a new environment to ensure that a new compilation takes place, and for setting a predetermined variable to a first value to control a position of a new data structure in the memory cache.

33. The system as claimed in claim 32 , wherein if the user does not have the privilege to access the better match routine in the routine environment, further comprising:

means for searching the data structures in the memory cache for another matching statement text and another matching base environment;

means for reexamining information in the data structure;

means for creating a new environment to ensure that a new compilation takes place if another matching base environment is not found; and

means for setting the predetermined variable to a second value to control the position of the new data structure in the memory cache.

34. The system as claimed in claim 33 , wherein if the matching statement text and the matching base environment are not found and the new compilation is successful, the storing means stores the new data structure in the memory cache.

35. The system as claimed in claim 34 , wherein if the predetermined variable is set to the first value and the new compilation is successful, the storing means further stores the new data structure in the memory cache before the data structure with the matching statement text and the matching base environment.

36. The system as claimed in claim 35 , wherein if the predetermined variable is set to the second value and the new compilation is successful, the storing means further stores the new data structure in the memory cache after the data structure with the matching statement text and the matching base environment.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 26, 2003
From: BIRD, PAUL M.; SNOWBELL, MICHAEL J.
To: INTERNATIONAL BUSINESS MACHINES CORPORATION
Reel/Frame 014448/0852 →
Priority Claims (1)
CA 2425046 · Apr 8, 2003 · national
Continuity (1)
Related Publication 20040205053A1 · Oct 14, 2004