> Full SurrealDB documentation index: https://surrealdb.com/docs/llms.txt

# dedupeTrace

Remove repeated entries from a query trace in the JavaScript SDK.

_(since v4.0.0)_

# `dedupeTrace()` {#dedupetrace}

The `dedupeTrace()` function removes the entries of a [query trace](/docs/reference/javascript/concepts/tracing-queries.md) that repeat an earlier entry, and keeps the first copy of each. A statement can report the same edge, reference or link on more than one frame, and `.responses()` and `.statements()` join the frames as they were sent.

**Import:**
```ts
import { dedupeTrace } from 'surrealdb';
```

**Source:** [utils/dedupe-trace.ts](https://github.com/surrealdb/surrealdb.js/blob/main/packages/sdk/src/utils/dedupe-trace.ts)

## Function signature

```ts
function dedupeTrace(trace: QueryTrace): QueryTrace
```

### Parameters
<table>
    <thead>
        <tr>
            <th>Parameter</th>
            <th>Type</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td><code>trace</code> <label label="required" /></td>
            <td><a href="/docs/reference/javascript/api/types/#querytrace"><code>QueryTrace</code></a></td>
            <td>The trace to remove repeated entries from. It is not changed.</td>
        </tr>
    </tbody>
</table>

### Returns
[`QueryTrace`](/docs/reference/javascript/api/types/#querytrace) - A trace that holds each entry once

Entries are identified by their record ids, and a link also by its field. Subscriptions are identified by their id. Variables are keyed by name, so they cannot repeat.

## Example

```ts
const [response] = await db
    .query('SELECT ->tagged->tag FROM post')
    .trace('relations')
    .responses();

if (response.success && response.trace) {
    const unique = dedupeTrace(response.trace);
}
```

## See also

- [Tracing queries](/docs/reference/javascript/concepts/tracing-queries.md) - Ask a query for its trace
- [Query.trace()](/docs/reference/javascript/api/queries/query.md#trace) - The method that asks for a trace
