# DbSummary

> Computes request-wide Database metrics without depending on the visible page or active filters.

[API reference](/docs/api/index.md) › [Debug Core](/docs/extensions/debug-core/reference/index.md) › [Panel](/docs/extensions/debug-core/reference/panel/index.md) › [Db](/docs/extensions/debug-core/reference/panel/db/index.md) › DbSummary

| final readonly class | `PHPForge\Debug\Panel\Db\DbSummary` |
| --- | --- |
| Source | [`src/Panel/Db/DbSummary.php`](https://github.com/php-forge/debug-core/blob/main/src/Panel/Db/DbSummary.php#L12) |

Computes request-wide Database metrics without depending on the visible page or active filters.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-callers"></span>`$callers` readonly | `array<string, int>` | Counts captured database queries by trace hash, excluding rows whose trace was not captured (empty hash). | `DbSummary` |
| <span id="property-count"></span>`$count` readonly | `int` | Counts the captured database queries. | `DbSummary` |
| <span id="property-duplicates"></span>`$duplicates` readonly | `int` | Counts queries marked as duplicates. | `DbSummary` |
| <span id="property-duration"></span>`$duration` readonly | `float` | Stores the total query duration in milliseconds. | `DbSummary` |
| <span id="property-types"></span>`$types` readonly | `array<string, string>` | Encountered SQL command verbs keyed by verb, so adapters can feed them straight into select filters. | `DbSummary` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`__construct()`](#method-__construct) | Creates request-wide database metrics. | `DbSummary` |
| [`excessiveCallerCount()`](#method-excessiveCallerCount) | Counts the call sites that issued at least `$threshold` statements, or `0` when the threshold is `null`. | `DbSummary` |
| [`hasWarning()`](#method-hasWarning) | Returns whether the request exceeds either threshold and must be surfaced as a toolbar warning. | `DbSummary` |
| [`isCritical()`](#method-isCritical) | Returns whether the query count exceeds `$threshold`, or `false` when the threshold is `null`. | `DbSummary` |

## Method details

### __construct() <span id="method-__construct"></span>

```php
public function __construct(list<PHPForge\Debug\Panel\Db\QueryRow> $rows)
```

Creates request-wide database metrics.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$rows` | `list<`[`QueryRow`](/docs/extensions/debug-core/reference/panel/db/queryrow/index.md)`>` | Captured query rows the metrics are computed from. |

### excessiveCallerCount() <span id="method-excessiveCallerCount"></span>

```php
public function excessiveCallerCount(int|null $threshold): int
```

Counts the call sites that issued at least `$threshold` statements, or `0` when the threshold is `null`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$threshold` | `int\|null` | Statements per call site that flag it, or `null` to disable the check. |

**Returns**

`int`: Number of call sites at or above the threshold.

### hasWarning() <span id="method-hasWarning"></span>

```php
public function hasWarning(int|null $criticalQueryThreshold, int|null $excessiveCallerThreshold): bool
```

Returns whether the request exceeds either threshold and must be surfaced as a toolbar warning.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$criticalQueryThreshold` | `int\|null` | Query count above which the request is critical, or `null` to disable. |
| `$excessiveCallerThreshold` | `int\|null` | Statements per call site that flag it, or `null` to disable. |

**Returns**

`bool`: `true` when either threshold is exceeded; `false` otherwise.

### isCritical() <span id="method-isCritical"></span>

```php
public function isCritical(int|null $threshold): bool
```

Returns whether the query count exceeds `$threshold`, or `false` when the threshold is `null`.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$threshold` | `int\|null` | Query count above which the request is critical, or `null` to disable the check. |

**Returns**

`bool`: `true` when the captured query count exceeds the threshold; `false` otherwise.