> ## Documentation Index
> Fetch the complete documentation index at: https://developers.stellar.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Evicted Keys Snapshot

> Reference documentation for the Evicted Keys Snapshot table in Hubble's Silver data dictionary.

## Table Metadata

| Property | Configuration |
| - | - |
| Natural Key(s) | ledger\_key\_hash, valid\_from |
| Partition Field(s) | valid\_to (MONTH partition) |
| Clustered Field(s) | ledger\_key\_hash |
| Documentation | [dbt docs](http://www.stellar-dbt-docs.com/#!/model/model.stellar_dbt_public.evicted_keys_snapshot) |

## Column Details

| Name | Description | Data Type | Domain Values | Required? | Notes |
| - | - | - | - | - | - |
| ledger\_key\_hash | Hash of the ledgerKey, which is a subset of the ledgerEntry. The subset of ledgerEntry fields depends on ledgerEntryType. | STRING | | Yes | |
| closed\_at | Timestamp in UTC when this ledger closed and committed. | TIMESTAMP | | Yes | Ledgers are expected to close \~every 5 seconds. |
| is\_evicted | Status flag indicating whether an entry is evicted or not. | BOOLEAN | false, true | Yes | false = key has been restored. |
| ledger\_sequence | The sequence number of this ledger, representing its order in the Stellar blockchain. | INTEGER | | Yes | Cluster Field. Unique per ledger. |
| valid\_from | The timestamp when this snapshot row was first inserted and became effective. | TIMESTAMP | | Yes | Helps track changes over time. |
| valid\_to | The timestamp when this row is no longer valid. | TIMESTAMP | | No | If null, the setting is currently active. |

## Example Business Questions

1. Evicted keys as of today

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT ledger_key_hash, is_evicted
FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
WHERE valid_to IS NULL
  AND is_evicted = TRUE
LIMIT 100
```

2. Point-in-time eviction status

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT ledger_key_hash, is_evicted
FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
WHERE ledger_key_hash = 'abc123'
  AND AND DATE('2025-03-10') BETWEEN DATE(valid_from) AND COALESCE(DATE(valid_to), '9999-12-31')
LIMIT 100
```

3. Monthly Key Restorations

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH with_lag AS (
  SELECT
    ledger_key_hash,
    valid_from,
    is_evicted,
    LAG(is_evicted) OVER (
      PARTITION BY ledger_key_hash
      ORDER BY valid_from
    ) AS prev_status
  FROM `crypto-stellar.snapshots.evicted_keys_snapshot`
)

SELECT
  DATE_TRUNC(valid_from, MONTH) AS month,
  COUNTIF(prev_status = TRUE AND is_evicted = FALSE) AS restorations_count
FROM with_lag
GROUP BY month
ORDER BY month
LIMIT 100
```
