Price alert Hurry up! Google SERP API from $0.03/1K API calls — prices likely to rise 10× from December 2026.Hurry up! Google SERP from $0.03/1K API calls — likely 10× from Dec 2026Google SERP $0.03/1K · likely 10× from Dec$0.03/1K · likely 10× in Dec Deposit Now

A SERP tracking database schema, with dedup and retention

By Anurag Pathak · · 13 min read

Store each daily check as a pointer to a SERP version, not as a new copy of the page. Five SQLite tables do it. A unique key stops a run counting twice, a content hash stops an unchanged SERP piling up, and raw JSON expires sooner than parsed rows.

Short answer: If you track a keyword list from one machine, use the five tables below in SQLite, which is enough at team scale. If a queue or a cron job can submit the same run twice, the unique key on (run_id, keyword_id) is not optional. If you only need one position per keyword per day, stay with the 100-line tracker table and skip this. For retention, my recommendation (not a standard) is 90 days for raw JSON and 24 months for parsed rows.

Why does one row per day stop being enough?

A table with one position per keyword per day cannot tell you what the rest of the page looked like on the day you dropped. That is the question a client asks, and it is the question a starter tracker cannot answer.

The tracker in Build a Google Rank Tracker in 100 Lines of Python stores ranks(snap_date, keyword, position, in_aio, top_url), one row per keyword per day. The local version in Local SEO Rank Tracking via API stores snapshots(snap_date, keyword, locality, position). Both suit a first tracker. This post starts where they stop.

Three needs push you past them: the whole SERP for a past date, the day a feature such as an AI Overview appeared, and re-parsing history after a parser fix, which needs the raw response.

What do the pages that cover this leave out?

Each page I opened covers one slice, and none gives schema, duplicate protection and retention together. I read four on 25 Nov 2026.

What four pages say about schema, duplicates and retention (opened 25 Nov 2026)
PageTablesDuplicate protectionRetention
Decodo (SERP API vendor, updated 24 Nov 2026)runs and rank_results, linked by run_id; selected fields plus two JSON columns, not the full responseA non-unique index; I found no unique constraintA cascade delete and a prune command; no recommended number that I saw
ScrapingAnt (scraping vendor, 25 Dec 2025)Bronze, silver and gold data-lake layers; raw SERPs kept as stored objects, partitioned by date and engineNot described"Store raw SERPs for at least 12–24 months"
SerpApi, SerpTrail (competitor, 23 Jul 2026)A Rails app on SQLite; a SearchRun record keeps a raw_response field with the full JSONNot mentionedNot stated
OpenSEO walkthrough (third-party code explainer, 1 Sep 2026)rankTrackingConfigs, rankCheckRuns, rankSnapshotsA composite unique constraint on (runId, trackingKeywordId, device) and onConflictDoNothingNot mentioned

Decodo is the closest to a full design, and I agree with its line "For a personal or team-scale tracker, SQLite is the right answer." OpenSEO is the only one with a unique key. ScrapingAnt gives the only retention number, a vendor's recommendation, not a measured need.

None of the four describes a content hash, so a SERP that did not change is stored again every day. That second kind of duplicate is the one that costs storage. The rest of this post is my own design, offered as a recommendation, not a standard.

Which five tables do you need?

You need keywords (what you track), runs (one batch), serps (one row per distinct SERP version), snapshots (one row per keyword per run) and results (parsed organic rows). serps is keyed by a hash of the content, so a SERP that stays the same for 30 days is one row, not 30.

Save this as schema.sql. I run Serpent, the API this site sells, so the examples below use it. The columns come from the documented format=full response in the response-format docs: each organic item has position, title, url, snippet and displayedUrl, and the metadata block carries booleans such as hasAiOverview and hasLocalPack.

PRAGMA foreign_keys = ON;
PRAGMA journal_mode = WAL;

-- What you track. NOT NULL DEFAULT '' on purpose: SQLite treats two NULLs as
-- different values inside a UNIQUE constraint, so a NULL location would let
-- the same keyword be inserted twice.
CREATE TABLE IF NOT EXISTS keywords (
  id        INTEGER PRIMARY KEY,
  query     TEXT NOT NULL,
  country   TEXT NOT NULL DEFAULT 'us',
  language  TEXT NOT NULL DEFAULT '',
  location  TEXT NOT NULL DEFAULT '',
  active    INTEGER NOT NULL DEFAULT 1,
  UNIQUE (query, country, language, location)
);

-- One batch of checks (your nightly job).
CREATE TABLE IF NOT EXISTS runs (
  id           INTEGER PRIMARY KEY,
  started_at   TEXT NOT NULL,          -- UTC, ISO 8601
  finished_at  TEXT,
  status       TEXT NOT NULL DEFAULT 'running'
);

-- One row per distinct SERP version, identified by a hash of its content.
-- body_json is the only big column, and the only one retention ever blanks.
CREATE TABLE IF NOT EXISTS serps (
  sha256               TEXT PRIMARY KEY,
  first_seen           TEXT NOT NULL,
  last_seen            TEXT NOT NULL,
  body_json            TEXT,           -- raw documented response; NULL once purged
  organic_count        INTEGER,        -- the columns below are NULL when parsing failed,
  has_ads              INTEGER,        -- 0 when the SERP simply had none
  ads_total            INTEGER,
  paa_count            INTEGER,
  has_featured_snippet INTEGER,
  has_ai_overview      INTEGER,
  has_knowledge_panel  INTEGER,
  has_local_pack       INTEGER
);

-- One row per keyword per run: "at this time, this keyword showed that SERP".
CREATE TABLE IF NOT EXISTS snapshots (
  id          INTEGER PRIMARY KEY,
  run_id      INTEGER NOT NULL REFERENCES runs(id)     ON DELETE CASCADE,
  keyword_id  INTEGER NOT NULL REFERENCES keywords(id) ON DELETE CASCADE,
  fetched_at  TEXT NOT NULL,
  serp_sha256 TEXT NOT NULL REFERENCES serps(sha256),
  UNIQUE (run_id, keyword_id)          -- layer 1: a run cannot count a keyword twice
);
CREATE INDEX IF NOT EXISTS snapshots_by_keyword_time ON snapshots (keyword_id, fetched_at);

-- Parsed organic rows, stored once per SERP version, not once per day.
CREATE TABLE IF NOT EXISTS results (
  serp_sha256   TEXT NOT NULL REFERENCES serps(sha256) ON DELETE CASCADE,
  position      INTEGER NOT NULL,
  url           TEXT,
  domain        TEXT,
  title         TEXT,
  snippet       TEXT,
  displayed_url TEXT,
  PRIMARY KEY (serp_sha256, position)
);
CREATE INDEX IF NOT EXISTS results_by_domain ON results (domain);

Three choices in that file are deliberate. location and language are NOT NULL DEFAULT '': in my local run a nullable location let the same keyword in twice, because SQLite treats two NULLs as different values inside a UNIQUE constraint. The feature columns are filled from metadata and array lengths, so "when did the AI Overview appear" is a query, not a re-parse; NULL means the parse failed and 0 means the SERP had none. And PRAGMA journal_mode = WAL follows Decodo's note that readers should not block on writers during concurrent runs.

The foreign_keys pragma is per connection: in my run an insert pointing at a missing serps row was accepted until I turned it on. Sitelinks, People Also Ask text and other nested blocks stay in the raw JSON only; add a table for them before it expires if you want that history. The code needs SQLite 3.24.0 or newer, the version that added ON CONFLICT upserts, per the SQLite upsert page.

What changes between two calls of the same query?

In the documented example only the meta block holds per-call values: meta.elapsed and meta.timestamp. Hash the response with meta removed, or the hash never matches and every day looks new.

These first two listings start snapshots.py: connection setup, one guard that absorbs parse failures, the hash, and a helper that lists the keys that differ between two responses. Save all the listings in order as one file.

import hashlib, json, logging, os, sqlite3, urllib.parse, urllib.request
from datetime import datetime, timedelta, timezone
from urllib.parse import urlparse

log = logging.getLogger("snapshots")


class DuplicateRun(Exception):
    pass


def connect(path, schema="schema.sql"):
    db = sqlite3.connect(path)
    db.execute("PRAGMA foreign_keys = ON")      # per connection, off by default
    db.executescript(open(schema).read())
    return db


def guard(fn, default=None):
    """The one place a parse failure is absorbed: log it, return the field's empty value."""
    try:
        return fn()
    except Exception as exc:
        log.warning("parse failed: %r", exc)
        return default
def content_hash(body):
    """Hash the response without `meta`, which holds the per-call values (elapsed, timestamp)."""
    stable = {k: v for k, v in body.items() if k != "meta"}
    canonical = json.dumps(stable, sort_keys=True, separators=(",", ":"), ensure_ascii=False)
    return hashlib.sha256(canonical.encode("utf-8")).hexdigest()


def changed_paths(a, b, prefix=""):
    """List the keys whose values differ between two responses; use it on two calls of the same query."""
    if isinstance(a, dict) and isinstance(b, dict):
        out = []
        for k in sorted(set(a) | set(b)):
            out += changed_paths(a.get(k), b.get(k), f"{prefix}.{k}" if prefix else k)
        return out
    if isinstance(a, list) and isinstance(b, list) and len(a) == len(b):
        return [p for i, (x, y) in enumerate(zip(a, b)) for p in changed_paths(x, y, f"{prefix}[{i}]")]
    return [] if a == b else [prefix]

On the saved sample, changed_paths returned ['meta.elapsed', 'meta.timestamp'] for a copy with a new timestamp. The hash of that copy without meta matched the original; the hash of the whole body did not.

That is the sample's answer, not a law: documented examples are the only responses I looked at. Before you trust the hash on live data, call the same query twice and run changed_paths on the two bodies; anything beyond meta that differs belongs in the filter.

What if one field fails to parse?

Put a guard around every field and every row, so a failure gives that field its own empty value and the rest still lands. You paid for the whole response, so you should keep all of it that parses.

guard is the only place an exception is absorbed, and this listing uses it for each feature column and each organic row. A row with no position takes its order in the list; a missing url leaves url and domain NULL.

def parse_features(body):
    r = body.get("results") if isinstance(body, dict) else None
    m = body.get("metadata") if isinstance(body, dict) else None
    return {
        "organic_count":        guard(lambda: len(r["organic"])),
        "has_ads":              guard(lambda: int(bool(m["hasAds"]))),
        "ads_total":            guard(lambda: int(r["ads"]["totalCount"])),
        "paa_count":            guard(lambda: len(r["peopleAlsoAsk"])),
        "has_featured_snippet": guard(lambda: int(bool(m["hasFeaturedSnippet"]))),
        "has_ai_overview":      guard(lambda: int(bool(m["hasAiOverview"]))),
        "has_knowledge_panel":  guard(lambda: int(bool(m["hasKnowledgePanel"]))),
        "has_local_pack":       guard(lambda: int(bool(m["hasLocalPack"]))),
    }


def parse_rows(body):
    items = guard(lambda: body["results"]["organic"], [])
    for i, it in enumerate(items, start=1):
        url = guard(lambda: it["url"])
        yield (
            guard(lambda: int(it["position"]), i),        # default: order in the list
            url,
            guard(lambda: urlparse(url).hostname.lower()),
            guard(lambda: it["title"]),
            guard(lambda: it["snippet"]),
            guard(lambda: it["displayedUrl"]),
        )

I tested it on a modified copy of the sample whose ads block was a string and whose second organic row had only a title. The serps row landed with ads_total NULL and every other feature column filled, and row 2 of results landed with a title and NULL for the rest. The failures went to a log line, not into the data.

How do you stop duplicates on both layers?

Layer 1 is the unique key on (run_id, keyword_id) plus ON CONFLICT DO NOTHING. Layer 2 is the content hash as the primary key of serps. Together they handle both kinds of repeat: a run submitted twice, and a SERP that did not change.

SQLite's upsert page says "If the insert operation would cause the conflict target uniqueness constraint to fail, then the insert is omitted and the corresponding DO NOTHING or DO UPDATE operation is performed instead." That is layer 1, and the same idea as OpenSEO's onConflictDoNothing.

ingest works in one transaction. It inserts the SERP version and its rows if the hash is new, or refreshes last_seen if it is known, then inserts the snapshot. If layer 1 fires, it raises, the transaction rolls back, and nothing from that call survives.

def ingest(db, run_id, keyword_id, body, fetched_at):
    """Store one response. Returns 'new-version', 'same-version' or 'duplicate-run'."""
    sha = content_hash(body)
    feats = parse_features(body)
    cols = ", ".join(feats)
    marks = ", ".join("?" for _ in feats)
    try:
        with db:                                           # one transaction
            cur = db.execute(
                f"INSERT INTO serps (sha256, first_seen, last_seen, body_json, {cols}) "
                f"VALUES (?, ?, ?, ?, {marks}) ON CONFLICT (sha256) DO NOTHING",
                (sha, fetched_at, fetched_at, json.dumps(body, ensure_ascii=False), *feats.values()))
            is_new = cur.rowcount == 1
            if is_new:
                db.executemany(
                    "INSERT INTO results VALUES (?, ?, ?, ?, ?, ?, ?) "
                    "ON CONFLICT (serp_sha256, position) DO NOTHING",
                    [(sha, *row) for row in parse_rows(body)])
            else:                                          # seen before: refresh last_seen,
                db.execute(                                # and restore a purged body
                    "UPDATE serps SET last_seen = MAX(last_seen, ?), "
                    "body_json = COALESCE(body_json, ?) WHERE sha256 = ?",
                    (fetched_at, json.dumps(body, ensure_ascii=False), sha))
            cur = db.execute(
                "INSERT INTO snapshots (run_id, keyword_id, fetched_at, serp_sha256) "
                "VALUES (?, ?, ?, ?) ON CONFLICT (run_id, keyword_id) DO NOTHING",
                (run_id, keyword_id, fetched_at, sha))
            if cur.rowcount == 0:                          # layer 1 fired: undo everything
                raise DuplicateRun()
    except DuplicateRun:
        return "duplicate-run"
    return "new-version" if is_new else "same-version"

To see it work, save the documented "best laptops 2025" example as sample.json beside schema.sql and snapshots.py, and run this.

import copy, json
import snapshots as S

db = S.connect("try.db")
db.execute("INSERT INTO keywords (query, country) VALUES ('best laptops 2025', 'us')")
body = json.load(open("sample.json"))            # the documented example, saved as sample.json

run1 = db.execute("INSERT INTO runs (started_at) VALUES ('2026-03-12T10:00:00Z')").lastrowid
print(S.ingest(db, run1, 1, body, "2026-03-12T10:00:00Z"))   # new-version
print(S.ingest(db, run1, 1, body, "2026-03-12T10:00:05Z"))   # duplicate-run: same run, same keyword

next_day = copy.deepcopy(body)                   # same SERP, only the per-call values differ
next_day["meta"].update(timestamp="2026-03-13T10:00:00.000Z", elapsed="2987ms")
run2 = db.execute("INSERT INTO runs (started_at) VALUES ('2026-03-13T10:00:00Z')").lastrowid
print(S.ingest(db, run2, 1, next_day, "2026-03-13T10:00:00Z"))  # same-version

changed = copy.deepcopy(next_day)                # the SERP itself changed
changed["results"]["organic"][0]["title"] = "Best Laptops 2025 - Updated Picks"
run3 = db.execute("INSERT INTO runs (started_at) VALUES ('2026-03-14T10:00:00Z')").lastrowid
print(S.ingest(db, run3, 1, changed, "2026-03-14T10:00:00Z"))   # new-version

for table in ("runs", "serps", "snapshots", "results"):
    print(table, db.execute(f"SELECT COUNT(*) FROM {table}").fetchone()[0])

I ran it locally on Python 3.15.2 and SQLite 3.54.1 on 25 Nov 2026; the response is the documented shape, not a call to the API. The output:

new-version
duplicate-run
same-version
new-version
runs 3
serps 2
snapshots 3
results 2

Three runs left three snapshot rows and two SERP versions. As a check that the key matters, the same double submit against a table without it left 2 rows instead of 1.

What can you ask once it is stored?

Three questions cover most client asks: where did we sit each day, what did the whole page look like on one day, and when did the SERP change. Save these as queries.sql.

-- A. Best position of a domain per day for one keyword
SELECT date(s.fetched_at) AS day, MIN(r.position) AS best_position
FROM snapshots s
JOIN results r ON r.serp_sha256 = s.serp_sha256
WHERE s.keyword_id = :keyword_id AND r.domain = :domain
GROUP BY day
ORDER BY day;

-- B. The whole SERP as it stood on one day
SELECT r.position, r.domain, r.title
FROM snapshots s
JOIN results r ON r.serp_sha256 = s.serp_sha256
WHERE s.keyword_id = :keyword_id AND date(s.fetched_at) = :day
ORDER BY r.position;

-- C. The days the SERP changed
SELECT date(s.fetched_at) AS changed_on
FROM snapshots s
WHERE s.serp_sha256 <> (
  SELECT p.serp_sha256 FROM snapshots p
  WHERE p.keyword_id = s.keyword_id AND p.fetched_at < s.fetched_at
  ORDER BY p.fetched_at DESC LIMIT 1)
ORDER BY changed_on;

I ran them on synthetic data, not a real SERP: 120 daily runs of one keyword, where I made the SERP change every 10th day and one domain drop from position 3 to 7 on 20 February. The 10-day rate is my assumption for the demo, not a measurement.

Query A returned 120 rows, from ('2026-01-01', 3) to ('2026-04-30', 7), with the move on 2026-02-20. Query B for that day returned all 10 rows, the domain at position 7. Query C returned 11 change days.

The 120 runs made 120 snapshot rows but only 12 SERP versions and 120 parsed rows. Days when the domain is absent give no row in query A, so join to a calendar if you need an explicit "not ranking".

How long should you keep raw JSON and parsed rows?

Run two clocks. My recommendation, not a standard, is to keep raw JSON for 90 days and parsed rows for 24 months. Raw JSON is large and is only useful soon after the fact; parsed rows are small and are the thing you chart.

The reasoning is about jobs. Raw JSON re-parses history after a parser fix and settles "what did the response say that day"; both usually come up within a quarter. Parsed rows feed charts, and 24 months compares a season with the same season a year earlier. Neither number is measured; change them to fit your contracts.

ScrapingAnt recommends longer for raw data: "Store raw SERPs for at least 12–24 months," because storage "is inexpensive relative to the value of being able to re-interpret old SERPs." That is fair if raw storage is cheap for you; the arithmetic below shows what dedup does to the bill.

The assumptions: 1,000 keywords checked daily for a year, 50 KB per stored body, and 30% of daily checks showing a changed SERP. I have not measured a real response size or change rate. The documented sample file is only 1,284 bytes, too small to stand for a real page.

Raw JSON held after one year (arithmetic on the assumptions above)
PolicyBodies heldSize at 50 KB each
Every body, no dedup365,00018.25 GB
Every body, hash dedup (30% change)109,5005.475 GB, about 5.5 GB
90 days of bodies, no dedup90,0004.5 GB
90 days of bodies, hash dedup27,000, plus at most 1,000 older bodies that are still current1.35 GB plus at most 0.05 GB, about 1.4 GB

Parsed rows scale with SERP versions, not days. At 10 organic rows per SERP a year is 3,650,000 rows without dedup and 1,095,000 with it; at 100 rows per SERP it is 36,500,000 against 10,950,000. Rows are small, which is why this clock can be long. The search docs say how to request more rows per search.

The first clock is one statement, wrapped in a function. It blanks bodies whose last_seen is older than the cutoff, so a SERP that is still current keeps its body however old its first sighting is.

def purge_raw(db, keep_days, now):
    """Clock 1: blank raw bodies not seen for keep_days. Parsed rows are untouched."""
    cutoff = (now - timedelta(days=keep_days)).strftime("%Y-%m-%dT%H:%M:%SZ")
    with db:
        return db.execute(
            "UPDATE serps SET body_json = NULL "
            "WHERE body_json IS NOT NULL AND last_seen < ?", (cutoff,)).rowcount

In my run, with 12 synthetic SERP versions of about 3 KB each, purge_raw(db, 90, now) blanked 3 bodies and left all 120 snapshots and 120 result rows, so old days stayed queryable. The file stayed at 163,840 bytes after the purge and dropped to 151,552 only after VACUUM; run VACUUM if you want the file to shrink.

The second clock is optional. Save this as forget.sql and run it with the foreign-key pragma on, because results rows leave through ON DELETE CASCADE. In my run a cutoff of 1 March 2026 took snapshots from 120 to 61, SERP versions from 12 to 7 and result rows from 120 to 70.

-- Clock 2 (optional): forget history older than :cutoff. Needs PRAGMA foreign_keys = ON,
-- because results rows disappear through ON DELETE CASCADE from serps.
DELETE FROM snapshots WHERE fetched_at < :cutoff;
DELETE FROM serps WHERE sha256 NOT IN (SELECT serp_sha256 FROM snapshots);

How do you fill the tables from the API?

Send one request per keyword with format=full and pass the response to ingest. /api/search fills the feature blocks where the SERP has them; /api/search/quick returns organic rows only and leaves the feature blocks empty, so the feature columns read 0 there. The /api/search and /api/search/quick docs say what fills on which engine, including the opt-in AI Overview text.

The last listing adds fetch and a nightly loop. A keyword whose request fails is skipped and the run is marked partial; the others still land.

def fetch(query, country="us", language="", location=""):
    params = {"q": query, "country": country, "format": "full"}
    if language:
        params["language"] = language
    if location:
        params["location"] = location
    req = urllib.request.Request(
        "https://apiserpent.com/api/search?" + urllib.parse.urlencode(params),
        headers={"X-API-Key": os.environ["SERPENT_API_KEY"]})
    with urllib.request.urlopen(req, timeout=60) as resp:
        return json.load(resp)


def run_nightly(db, fetch=fetch):
    now = lambda: datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
    run_id = db.execute("INSERT INTO runs (started_at) VALUES (?)", (now(),)).lastrowid
    db.commit()
    failed = 0
    keywords = db.execute(
        "SELECT id, query, country, language, location FROM keywords WHERE active = 1").fetchall()
    for kid, query, country, language, location in keywords:
        try:
            body = fetch(query, country, language, location)
            if not body.get("success"):
                raise ValueError("response says success is not true")
        except Exception as exc:
            log.warning("skipped %r: %r", query, exc)
            failed += 1
            continue
        ingest(db, run_id, kid, body, now())
    with db:
        db.execute("UPDATE runs SET finished_at = ?, status = ? WHERE id = ?",
                   (now(), "partial" if failed else "done", run_id))
    return run_id

I made no call to the API for this post. I ran run_nightly with a stub that returns the documented example and times out for one keyword: both nights were marked partial and 4 snapshot rows landed. A fake urlopen showed fetch building https://apiserpent.com/api/search?q=best+laptops+2025&country=us&format=full with the X-API-Key header.

Set SERPENT_API_KEY before a real run. Searches are from $0.03 per 1K API calls, pay as you go, no subscription; see pricing, checked 25 Nov 2026.

Where does this design stop working?

It stops at the edges of SQLite, and in some places I could not test. Check each of these before you rely on it.

At hundreds of thousands of keywords, read Bulk Keyword Rank Checking for the batch side and treat this schema as the model.

Which setup should you pick?

How we checked this

Sources: four vendor, competitor or third-party pages (Decodo, ScrapingAnt, SerpApi, an OpenSEO code walkthrough), the SQLite upsert page, our docs for the response shape and our pricing page. I read the four pages and their quoted sentences on 25 Nov 2026; the dates in the table are the ones each page shows. The code ran locally on 25 Nov 2026 on Python 3.15.2 with SQLite 3.54.1 (the schema also loaded in the sqlite3 shell, version 3.43.2), against the documented example response and synthetic variants. No call to the API was made.

What I could not verify: the Google results for this keyword (I did not read them; the pages above came from a web-search result list); an npm package listing (socket.dev) that refused my read; real response sizes; how often real SERPs change; whether meta is the only per-call part of a live response; and whether ScrapingAnt's 12–24 months is anything beyond a recommendation. The 90-day and 24-month windows and the 50 KB and 30% figures are my assumptions.

Fill the tables with one call per keyword

Searches are from $0.03 per 1K API calls, pay as you go, no subscription (checked 25 Nov 2026), and you get 10 free calls to try the response shape.

Get Your Free API Key

Explore: Rank Tracking API · Playground · Docs · Pricing

FAQ

Should I store the raw JSON at all?

Yes, for a limited time. Only the raw response lets you re-run a fixed parser over history or settle a dispute about what a response held. SerpApi's SerpTrail keeps the full JSON in a raw_response field. Keep it on a short clock, because it is the large column, and keep parsed rows much longer.

Is SQLite enough for a SERP tracking database?

At personal or team scale, yes. Decodo says "For a personal or team-scale tracker, SQLite is the right answer," and SerpTrail also runs on SQLite. Use WAL mode and one writer process. For several writers, Decodo says you move to Postgres with the same schema; I have not designed a Postgres version of this schema, so I cannot say how it would differ.

How do I stop duplicate rows in a rank tracker?

Use two layers. A unique key on (run_id, keyword_id) with ON CONFLICT DO NOTHING stops one run counting a keyword twice, and needs SQLite 3.24.0 or newer. A content hash as the primary key of the SERP table stops an unchanged SERP being stored again each day, but only if you hash the response without its per-call values.

Why hash the body without meta?

Because meta holds per-call values: meta.elapsed and meta.timestamp in the documented example. A hash over the whole body never matches, while the hash without meta matched on two otherwise identical copies of the saved sample. Check live responses the same way, because I could only test the documented example.

How long should I keep SERP data?

My recommendation, not a standard, is 90 days for raw JSON and 24 months for parsed rows. ScrapingAnt suggests at least 12–24 months for raw SERPs, which is a vendor's recommendation. Set raw retention by the jobs you need it for, and parsed retention by the longest comparison you want to chart.

Sources

Official docs and pricing (checked 25 November 2026):

Vendor and competitor pages (read 25 November 2026):

Third-party explainer (read 25 November 2026):

Related Posts