# US 8,577,871 B2 · Method and mechanism for out-of-the-box real-time SQL monitoring

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 8,577,871 B2
- Document ID: US8577871B2
- Status: Granted
- Kind: B2
- Application number: 12/060,117
- Filed: 2008-03-31
- Published: 2009-10-01
- Granted: 2013-11-05
- Earliest claimed: 2008-03-31
- Assignees: Oracle International Corporation
- Applicants: Benoit Dageville; Venkateshwaran Venkataramani
- Inventors: Benoit Dageville; Venkateshwaran Venkataramani
- Web page: https://patentgrep.com/patent/US8577871B2

## CPC

- G06F 16/217: {Database tuning (G06F16/2282 takes precedence; database performance monitoring G06F11/3409)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Methods, systems, and computer program products for monitoring database queries and executions is disclosed. The query syntax may conform to the structured query language (SQL). The approach supports various performance statistics to be monitored at each step of the query statement's execution plan and for each row processed in order to meet requirements of a near real-time query monitoring solution. Such statistics include timing information plus some miscellaneous statistics like the number of rows processed, the amount of memory used, the amount of data spilled to disk, etc.

## Claims

### Claim 1

A method for near real-time monitoring of a query in a database system, comprising:
determining whether or not to monitor an execution of the query;
in response to determination that the execution of the query is to be monitored, periodically collecting, by using a computer system comprising a processor, a plurality of statistics from the execution of the query;
storing the plurality of periodically collected statistics during the execution of the query;
periodically gathering performance statistics from the plurality of stored statistics using background processes for analysis during the execution of the query;
storing the periodically gathered performance statistics in a volatile or non-volatile computer-useable medium;
estimating a time to completion for the query by analyzing the stored performance statistics.

### Claim 2 (depends on 1)

The method of claim 1, wherein the query comprises a query syntax conforming to structured query language (SQL).

### Claim 3 (depends on 1)

The method of claim 1, further comprises deriving timing information at an execution plan level based at least in part upon the gathered performance statistics.

### Claim 4 (depends on 1)

The method of claim 1, further comprising deleting the stored performance statistics.

### Claim 5 (depends on 1)

The method of claim 1, wherein the stored performance statistics comprise performance metrics includes statement elapsed time, CPU time, I/O wait time, and number of reads and writes.

### Claim 6 (depends on 1)

The method of claim 1, wherein the near real-time monitoring is automatically initiated.

### Claim 7 (depends on 1)

The method of claim 1, wherein a combination of heuristics and sampling are used to determine the start of near real-time monitoring.

### Claim 8 (depends on 7)

The method of claim 7, wherein the heuristics comprises automatically turning on monitoring when the query runs parallel to one or more other queries in the execution.

### Claim 9 (depends on 7)

The method of claim 7, wherein the heuristics comprises automatically turning on monitoring when the query has consumed at least five seconds of CPU and/or I/O time in the execution.

### Claim 10 (depends on 1)

The method of claim 1, further comprises maintaining plan level timing statistics using a sampling technique.

### Claim 11 (depends on 1)

The method of claim 1, further comprising storing a process participating in a parallel execution as separate entries in a shared memory.

### Claim 12 (depends on 11)

The method of claim 11, further comprising:
aggregating one or more skews in the parallel execution; and
assisting in determination of the performance statistics of the query by using gathered statistics of the process in the parallel execution of the query.

### Claim 13 (depends on 1)

The method of claim 1, wherein the gathered statistics comprises timing information.

### Claim 14 (depends on 1)

The method of claim 1, wherein the gathered statistics comprises cardinality of intermediate results of the execution of the query.

### Claim 15 (depends on 1)

The method of claim 1, wherein the gathered performance statistics are inputs to self-tune an execution plan of the query before the execution of the query is finished.

### Claim 16 (depends on 15)

The method of claim 15, further comprising detecting bad estimates and/or bad optimizer costing.

### Claim 17 (depends on 1)

The method of claim 1, further comprising determining which intermediate step of the execution is active.

### Claim 18 (depends on 1)

The method of claim 1, further comprises determining an amount of time it takes to complete each step of the execution and/or the query.

### Claim 19

A computer program product comprising a computer useable medium having executable code to execute a process by a processor for monitoring a query in a database system, the process comprising:
determining whether or not to monitor an execution of the query;
in response to determination that the execution of the query is to be monitored, periodically collecting, plurality of statistics from the execution of the query;
storing the plurality of periodically collected statistics during the execution of the query;
periodically gathering performance statistics from the plurality of stored statistics using background processes for analysis during the execution of the query;
storing the periodically gathered performance statistics in a volatile or non-volatile computer-useable medium;
estimating a time to completion for the query by analyzing the stored performance statistics.

### Claim 20 (depends on 19)

The computer program product of claim 19, wherein the query comprises a query syntax conforming to structured query language (SQL).

### Claim 21 (depends on 19)

The computer program product of claim 19, wherein the gathered performance statistics are inputs to self-tune an execution plan of the query before the execution of the query is finished.

### Claim 22

A system for monitoring a query in a database system, comprising:
a processor;
a memory for holding programmable code; and
wherein the programmable code includes instructions executable by the processor for:
determining whether or not to monitor an execution of the query;
in response to determination that the execution of the query is to be monitored, periodically collecting, a plurality of statistics from the execution of the query;
storing the plurality of periodically collected statistics during the execution of the query;
periodically gathering performance statistics from the plurality of stored statistics using background processes for analysis during the execution of the query;
storing the periodically gathered performance statistics in a volatile or non-volatile computer-useable medium;
estimating a time to completion for the query by analyzing the stored performance statistics.

### Claim 23 (depends on 22)

The system of claim 22, wherein the query comprises a query syntax conforming to structured query language (SQL).

### Claim 24 (depends on 22)

The system of claim 22, wherein the gathered performance statistics are inputs to self-tune an execution plan of the query before the execution of the query is finished.
