From cf6633a6b5c445bf42f614f5e234acccae6c3b31 Mon Sep 17 00:00:00 2001 From: Russiankryt Date: Thu, 3 Dec 2026 17:20:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=A0=202:=20=D1=80=D0=B5=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BC=D0=B5=D1=81=D1=81?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=B6=D0=B5=D1=80=D0=B0=20=D0=B8=20=D1=81?= =?UTF-8?q?=D1=86=D0=B5=D0=BD=D0=B0=D1=80=D0=B8=D0=B8=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 16 +- .gitattributes | 1 + Dockerfile | 9 + REPORT.md | 51 +- compose.yaml | 70 + evidence/history-windows.json | 9952 +++++++++++++++++++++++++++ evidence/local-checks.txt | 3 + requirements.txt | 3 + scripts/bootstrap.py | 37 + scripts/history_experiment.py | 156 + scripts/restart.cmd | 6 + scripts/restart.sh | 7 + src/app.py | 409 ++ src/auth.py | 91 + src/db.py | 135 + src/migrations/001_messenger.sql | 33 + student-tests/auth_and_atomicity.py | 85 + 17 files changed, 11027 insertions(+), 37 deletions(-) create mode 100644 .gitattributes create mode 100644 Dockerfile create mode 100644 compose.yaml create mode 100644 evidence/history-windows.json create mode 100644 evidence/local-checks.txt create mode 100644 requirements.txt create mode 100644 scripts/bootstrap.py create mode 100644 scripts/history_experiment.py create mode 100644 scripts/restart.cmd create mode 100755 scripts/restart.sh create mode 100644 src/app.py create mode 100644 src/auth.py create mode 100644 src/db.py create mode 100644 src/migrations/001_messenger.sql create mode 100644 student-tests/auth_and_atomicity.py diff --git a/.dockerignore b/.dockerignore index bc16e556..212b21ea 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,20 +1,8 @@ .git -.github .env .env.* -!.env.example secrets certs -volumes -data -backups -*.key -*.pem -*.p12 -*.pfx -*.jks -.venv -__pycache__ -node_modules evidence -.DS_Store +**/__pycache__ +.venv diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dfdb8b77 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.sh text eol=lf diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ac70f2fe --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.12.12-slim-bookworm +WORKDIR /app +ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 PYTHONPATH=/app/src +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt +COPY src ./src +USER 10001:10001 +EXPOSE 8080 +CMD ["python", "-m", "app"] diff --git a/REPORT.md b/REPORT.md index e42f2b05..66888429 100644 --- a/REPORT.md +++ b/REPORT.md @@ -1,37 +1,42 @@ # Отчёт — лабораторная 2 -- Автор, группа: TODO -- Целевая оценка; выбранный трек 5, если нужен: TODO -- Commit/PR: TODO после публикации -- Использованные источники, библиотеки и помощь ИИ: TODO +- Автор и группа — Шемрук Марк, БВТ2304. +- Целевая оценка — 5. Трек 2. План запроса и восстановление. +- Ветка решения — `solution/bvt2304-shemruk`. Ссылка на PR появится после отправки. +- Источники — контракт курса, собственная ЛР1, официальные руководства используемых компонентов. Codex помог с реализацией, проверками и отчётом. Присланные чужие реализации использовались для сверки тем и сценариев курса. -## Запуск из чистого clone +## Запуск -TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных. +На Windows команды выполняются в PowerShell из корня репозитория. Нужны Python 3.11+, Docker Desktop с Linux Engine и Compose. Образ API использует Python 3.12.12. Подготовьте свободные локальные порты. Рабочие файлы .env и secrets создаёт bootstrap. Точные версии зависимостей находятся в `requirements.txt` и `compose.yaml`. -## Архитектура и решения +```powershell +python -X utf8 scripts/check_contract.py +python -X utf8 scripts/bootstrap.py +docker compose config --quiet +docker compose up -d --build --wait +``` -TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab1, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации. +На Linux вместо `python -X utf8` можно использовать `python3 -X utf8`. Безопасная остановка — `docker compose down`. Она сохраняет named volumes. Преднамеренный сброс отдельного учебного окружения — `docker compose down -v`. -## Доказательства критериев +## Архитектура и границы гарантий -| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства | -| --- | --- | --- | --- | -| Публичный smoke | make test | TODO | TODO | -| Остальные пункты уровня 3 | TODO | TODO | TODO | -| Все пункты уровня 4, если заявлен | TODO | TODO | TODO | -| Выбранный трек 5, если заявлен | TODO | TODO | TODO | +Клиент → HTTP API → PostgreSQL 17.6 и Redis 7.4.6. Из ЛР1 сохранены маршруты, валидация, проверка членства, пагинация и учебный сервер Python. Составная запись чата и участников выполняется в одной транзакции. Внешние ключи защищают членство, уникальный индекс исключает вторую запись username. PostgreSQL хранит только scrypt-хеш с солью. Basic обменивается на Bearer-токен из 32 случайных байтов. Redis хранит хеш токена и ID пользователя до абсолютного срока истечения. Logout удаляет запись. Redis пишет AOF с `appendfsync always` в отдельный volume. При недоступности Redis защищённый запрос завершается 503. Пул PostgreSQL ограничен восемью соединениями, `statement_timeout` равен 4 с. -TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены. +Сортировка истории использует пару `(created_at, id)`, индекс начинается с `chat_id`. Сервер читает на одну строку больше размера страницы для определения наличия следующей. HMAC связывает cursor с конкретным чатом. Для двух HTTP-страниц составной снимок не открывается. Конкурентная запись с более ранней парой может остаться до курсора, например при изменении времени на сервере. -## Эксперименты и отказы +## Проверки и результаты -TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения. +```powershell +python -X utf8 tests/smoke.py +python -X utf8 tests/resilience.py --mode persistence --action-script scripts/restart.cmd +``` -| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных | -| --- | --- | --- | --- | -| TODO | TODO | TODO | TODO | +Статическая проверка контракта, синтаксис и конфигурация Compose прошли. Публичный HTTP smoke прошёл на локальном PostgreSQL 18.0 с тестовой заменой Redis. Этот прогон проверяет API. Фактические отказы контейнеров и Compose-эксперименты требуют отдельного запуска. -## Ограничения и следующие шаги +### Эксперимент PostgreSQL -TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза. +`python -X utf8 scripts/history_experiment.py` создаёт две временные базы, заполняет 120 000 сообщений для 100 неодинаковых чатов, прогревает каждый запрос и снимает пять планов для OFFSET и keyset до и после композитного индекса. Записывает `EXPLAIN (ANALYZE, BUFFERS, WAL, FORMAT JSON)`. Вставка 2000 строк измеряется в транзакции с ROLLBACK. Бэкап и восстановление идут в отдельную базу. Проверяются количество в каждом чате и MD5 выборочных записей. Маркер, добавленный после бэкапа, в восстановленной базе отсутствует. + +Наблюдение на локальном Windows PostgreSQL 18.0, 72 000 строк в самом большом чате. С составным индексом keyset на глубине 80% занял 0,092 мс против 13,403 мс у OFFSET. Без индекса медианы составили 87,957 и 162,259 мс соответственно. В медиане 2000 вставок заняли 16,468 мс при одном PK и 29,723 мс с новым индексом. WAL вырос с 556 073 до 784 089 байт. Бэкап 3 477 911 байт занял 0,655 с. Восстановление заняло 0,926 с, 120 000 строк, контрольные суммы и счётчики совпали. Эти измерения относятся к синтетической таблице и прогретому локальному процессу. Сценарий Compose для PostgreSQL 17.6 включён для воспроизведения. Сохранение после смерти узла, PID и холодный кэш этим замером не оценивались. Сырые наблюдения лежат в `evidence/history-windows.json`. + +`python -X utf8 student-tests/auth_and_atomicity.py --dependency-stops` проверяет гонку регистрации, откат, отзыв токена и реакцию на остановку DB/Redis. Expiry запускается отдельно, сначала задать `SESSION_TTL_SECONDS=2` в окружении и пересоздать API, затем выполнить скрипт с `--short-ttl-only`. diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 00000000..c423f527 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,70 @@ +x-app: &app + build: . + image: shemruk-messenger-lab2:local + cpus: 1.0 + mem_limit: 320m + init: true + environment: + DATABASE_URL_FILE: /run/secrets/database_url + CACHE_URL_FILE: /run/secrets/cache_url + CURSOR_KEY_FILE: /run/secrets/cursor_key + SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600} + secrets: [database_url, cache_url, cursor_key] + +services: + db: + image: postgres:17.6-bookworm + cpus: 1.0 + mem_limit: 512m + environment: + POSTGRES_USER: messenger + POSTGRES_DB: messenger + POSTGRES_PASSWORD_FILE: /run/secrets/db_password + secrets: [db_password] + volumes: [postgres_data:/var/lib/postgresql/data] + healthcheck: + test: [CMD-SHELL, pg_isready -U messenger -d messenger -h 127.0.0.1] + interval: 2s + timeout: 2s + retries: 20 + cache: + image: redis:7.4.6-bookworm + cpus: 0.5 + mem_limit: 128m + command: [redis-server, /run/secrets/redis_config] + secrets: [redis_config, cache_password] + volumes: [redis_data:/data] + healthcheck: + test: [CMD-SHELL, 'REDISCLI_AUTH=$$(cat /run/secrets/cache_password) redis-cli ping | grep -qx PONG'] + interval: 2s + timeout: 2s + retries: 20 + migrate: + <<: *app + command: [python, -m, db] + depends_on: + db: {condition: service_healthy} + api: + <<: *app + ports: ["127.0.0.1:${HTTP_PORT:-8080}:8080"] + stop_grace_period: 12s + depends_on: + migrate: {condition: service_completed_successfully} + cache: {condition: service_healthy} + healthcheck: + test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=3)"] + interval: 2s + timeout: 4s + retries: 20 + +volumes: + postgres_data: + redis_data: + +secrets: + database_url: {file: ./secrets/database_url} + db_password: {file: ./secrets/db_password} + cache_url: {file: ./secrets/cache_url} + cache_password: {file: ./secrets/cache_password} + cursor_key: {file: ./secrets/cursor_key} + redis_config: {file: ./secrets/redis.conf} diff --git a/evidence/history-windows.json b/evidence/history-windows.json new file mode 100644 index 00000000..c1035d8e --- /dev/null +++ b/evidence/history-windows.json @@ -0,0 +1,9952 @@ +{ + "hypothesis": "Composite index bounds keyset read work at the cost of extra write I/O", + "server": "18.0", + "repeat_count": 5, + "baseline_primary_key_only": { + "read": { + "1": { + "rows": 72000, + "offset": 57600, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15693.44, + "Total Cost": 15693.56, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 156.296, + "Actual Total Time": 156.301, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15549.44, + "Total Cost": 15729.94, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 148.497, + "Actual Total Time": 155.118, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 11728, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 0.105, + "Actual Total Time": 123.785, + "Actual Rows": 72000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 1)", + "Rows Removed by Filter": 48000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.151, + "Triggers": [], + "Execution Time": 171.731 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15693.44, + "Total Cost": 15693.56, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 143.934, + "Actual Total Time": 143.94, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15549.44, + "Total Cost": 15729.94, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 135.102, + "Actual Total Time": 142.64, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 11728, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 0.091, + "Actual Total Time": 109.367, + "Actual Rows": 72000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 1)", + "Rows Removed by Filter": 48000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.624, + "Triggers": [], + "Execution Time": 163.855 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15693.44, + "Total Cost": 15693.56, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 135.159, + "Actual Total Time": 135.165, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15549.44, + "Total Cost": 15729.94, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 128.53, + "Actual Total Time": 133.906, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 11728, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 0.132, + "Actual Total Time": 105.74, + "Actual Rows": 72000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 1)", + "Rows Removed by Filter": 48000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.185, + "Triggers": [], + "Execution Time": 151.021 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15693.44, + "Total Cost": 15693.56, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 141.508, + "Actual Total Time": 141.514, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15549.44, + "Total Cost": 15729.94, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 134.89, + "Actual Total Time": 140.379, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 11728, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 0.15, + "Actual Total Time": 108.319, + "Actual Rows": 72000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 1)", + "Rows Removed by Filter": 48000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.394, + "Triggers": [], + "Execution Time": 158.717 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15693.44, + "Total Cost": 15693.56, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 144.552, + "Actual Total Time": 144.559, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 15549.44, + "Total Cost": 15729.94, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 134.691, + "Actual Total Time": 142.873, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 11728, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 1261, + "Temp Written Blocks": 1471, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 72200, + "Plan Width": 152, + "Actual Startup Time": 0.394, + "Actual Total Time": 107.284, + "Actual Rows": 72000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 1)", + "Rows Removed by Filter": 48000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 9.684, + "Triggers": [], + "Execution Time": 162.259 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 5762.63, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 83.911, + "Actual Total Time": 90.93, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Gather Merge", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 10018.29, + "Plan Rows": 37390, + "Plan Width": 152, + "Actual Startup Time": 83.905, + "Actual Total Time": 90.919, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Workers Planned": 1, + "Workers Launched": 1, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4756.92, + "Total Cost": 4811.9, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 54.155, + "Actual Total Time": 54.166, + "Actual Rows": 40.0, + "Actual Loops": 2, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [ + { + "Worker Number": 0, + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory" + } + ], + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": true, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4026.29, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 30.823, + "Actual Total Time": 53.748, + "Actual Rows": 7200.0, + "Actual Loops": 2, + "Disabled": false, + "Filter": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Filter": 52800, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [] + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 90, + "Shared Read Blocks": 33, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.591, + "Triggers": [], + "Execution Time": 90.998 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 5762.63, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 80.501, + "Actual Total Time": 84.434, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Gather Merge", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 10018.29, + "Plan Rows": 37390, + "Plan Width": 152, + "Actual Startup Time": 80.499, + "Actual Total Time": 84.429, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Workers Planned": 1, + "Workers Launched": 1, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4756.92, + "Total Cost": 4811.9, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 50.425, + "Actual Total Time": 50.426, + "Actual Rows": 50.0, + "Actual Loops": 2, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [ + { + "Worker Number": 0, + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory" + } + ], + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": true, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4026.29, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 29.753, + "Actual Total Time": 49.929, + "Actual Rows": 7200.0, + "Actual Loops": 2, + "Disabled": false, + "Filter": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Filter": 52800, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [] + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 87, + "Shared Read Blocks": 36, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.051, + "Triggers": [], + "Execution Time": 84.497 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 5762.63, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 163.548, + "Actual Total Time": 167.965, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Gather Merge", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 10018.29, + "Plan Rows": 37390, + "Plan Width": 152, + "Actual Startup Time": 163.545, + "Actual Total Time": 167.959, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Workers Planned": 1, + "Workers Launched": 1, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4756.92, + "Total Cost": 4811.9, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 57.007, + "Actual Total Time": 57.009, + "Actual Rows": 25.0, + "Actual Loops": 2, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [ + { + "Worker Number": 0, + "Sort Method": "quicksort", + "Sort Space Used": 25, + "Sort Space Type": "Memory" + } + ], + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": true, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4026.29, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 30.215, + "Actual Total Time": 56.572, + "Actual Rows": 7200.0, + "Actual Loops": 2, + "Disabled": false, + "Filter": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Filter": 52800, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [] + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 89, + "Shared Read Blocks": 34, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 8.928, + "Triggers": [], + "Execution Time": 168.117 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 5762.63, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 78.836, + "Actual Total Time": 85.561, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Gather Merge", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 10018.29, + "Plan Rows": 37390, + "Plan Width": 152, + "Actual Startup Time": 78.834, + "Actual Total Time": 85.556, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Workers Planned": 1, + "Workers Launched": 1, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4756.92, + "Total Cost": 4811.9, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 54.367, + "Actual Total Time": 54.369, + "Actual Rows": 40.0, + "Actual Loops": 2, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [ + { + "Worker Number": 0, + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory" + } + ], + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": true, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4026.29, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 28.75, + "Actual Total Time": 53.82, + "Actual Rows": 7200.0, + "Actual Loops": 2, + "Disabled": false, + "Filter": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Filter": 52800, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [] + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 90, + "Shared Read Blocks": 33, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.599, + "Triggers": [], + "Execution Time": 85.626 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 5762.63, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 79.005, + "Actual Total Time": 87.889, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Gather Merge", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5756.93, + "Total Cost": 10018.29, + "Plan Rows": 37390, + "Plan Width": 152, + "Actual Startup Time": 79.002, + "Actual Total Time": 87.882, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Workers Planned": 1, + "Workers Launched": 1, + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4756.92, + "Total Cost": 4811.9, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 50.93, + "Actual Total Time": 50.936, + "Actual Rows": 35.5, + "Actual Loops": 2, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 12, + "Shared Read Blocks": 2795, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [ + { + "Worker Number": 0, + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory" + } + ], + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": true, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4026.29, + "Plan Rows": 21994, + "Plan Width": 152, + "Actual Startup Time": 29.249, + "Actual Total Time": 50.481, + "Actual Rows": 7200.0, + "Actual Loops": 2, + "Disabled": false, + "Filter": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Filter": 52800, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Workers": [] + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.745, + "Triggers": [], + "Execution Time": 87.957 + } + ] + } + }, + "2": { + "rows": 18000, + "offset": 14400, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5575.55, + "Total Cost": 5575.68, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 146.111, + "Actual Total Time": 146.124, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5539.55, + "Total Cost": 5583.79, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 143.063, + "Actual Total Time": 145.835, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 76.487, + "Actual Total Time": 133.108, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 2)", + "Rows Removed by Filter": 102000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.789, + "Triggers": [], + "Execution Time": 162.1 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5575.55, + "Total Cost": 5575.68, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 132.962, + "Actual Total Time": 132.967, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5539.55, + "Total Cost": 5583.79, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 131.828, + "Actual Total Time": 132.68, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 77.008, + "Actual Total Time": 125.124, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 2)", + "Rows Removed by Filter": 102000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 11.898, + "Triggers": [], + "Execution Time": 153.537 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5575.55, + "Total Cost": 5575.68, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 126.305, + "Actual Total Time": 126.31, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5539.55, + "Total Cost": 5583.79, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 125.163, + "Actual Total Time": 126.01, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 70.366, + "Actual Total Time": 116.8, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 2)", + "Rows Removed by Filter": 102000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.1, + "Triggers": [], + "Execution Time": 135.078 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5575.55, + "Total Cost": 5575.68, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 125.374, + "Actual Total Time": 125.379, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5539.55, + "Total Cost": 5583.79, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 124.285, + "Actual Total Time": 125.097, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 74.028, + "Actual Total Time": 117.118, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 2)", + "Rows Removed by Filter": 102000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 85, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.288, + "Triggers": [], + "Execution Time": 138.244 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5575.55, + "Total Cost": 5575.68, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 125.38, + "Actual Total Time": 125.385, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5539.55, + "Total Cost": 5583.79, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 124.255, + "Actual Total Time": 125.099, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 17696, + "Plan Width": 152, + "Actual Startup Time": 75.701, + "Actual Total Time": 118.182, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 2)", + "Rows Removed by Filter": 102000, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 87, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.032, + "Triggers": [], + "Execution Time": 140.896 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5056.26, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 122.452, + "Actual Total Time": 122.458, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5068.56, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 122.45, + "Actual Total Time": 122.454, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 88.135, + "Actual Total Time": 122.245, + "Actual Rows": 3600.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Filter": 116400, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.019, + "Triggers": [], + "Execution Time": 122.509 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5056.26, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 113.632, + "Actual Total Time": 113.637, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5068.56, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 113.63, + "Actual Total Time": 113.632, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 80.691, + "Actual Total Time": 113.399, + "Actual Rows": 3600.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Filter": 116400, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.582, + "Triggers": [], + "Execution Time": 113.687 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5056.26, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 125.022, + "Actual Total Time": 125.029, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5068.56, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 125.02, + "Actual Total Time": 125.025, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 87.171, + "Actual Total Time": 124.762, + "Actual Rows": 3600.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Filter": 116400, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.257, + "Triggers": [], + "Execution Time": 125.097 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5056.26, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 119.774, + "Actual Total Time": 119.779, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5068.56, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 119.772, + "Actual Total Time": 119.775, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 84.84, + "Actual Total Time": 119.556, + "Actual Rows": 3600.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Filter": 116400, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.725, + "Triggers": [], + "Execution Time": 119.824 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5056.26, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 107.818, + "Actual Total Time": 107.823, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5056.13, + "Total Cost": 5068.56, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 107.816, + "Actual Total Time": 107.818, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "top-N heapsort", + "Sort Space Used": 37, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 4971, + "Plan Width": 152, + "Actual Startup Time": 77.758, + "Actual Total Time": 107.587, + "Actual Rows": 3600.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Filter": 116400, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.96, + "Triggers": [], + "Execution Time": 107.874 + } + ] + } + }, + "10": { + "rows": 306, + "offset": 244, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.34, + "Total Cost": 4304.47, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 104.269, + "Actual Total Time": 104.273, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4303.73, + "Total Cost": 4304.5, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 104.249, + "Actual Total Time": 104.263, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 77.797, + "Actual Total Time": 104.058, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 10)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.364, + "Triggers": [], + "Execution Time": 104.326 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.34, + "Total Cost": 4304.47, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 114.777, + "Actual Total Time": 114.78, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4303.73, + "Total Cost": 4304.5, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 114.764, + "Actual Total Time": 114.772, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 85.044, + "Actual Total Time": 114.552, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 10)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.194, + "Triggers": [], + "Execution Time": 114.82 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.34, + "Total Cost": 4304.47, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 126.213, + "Actual Total Time": 126.218, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4303.73, + "Total Cost": 4304.5, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 126.193, + "Actual Total Time": 126.208, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 90.802, + "Actual Total Time": 125.969, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 10)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.798, + "Triggers": [], + "Execution Time": 126.263 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.34, + "Total Cost": 4304.47, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 119.49, + "Actual Total Time": 119.495, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4303.73, + "Total Cost": 4304.5, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 119.473, + "Actual Total Time": 119.486, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 90.362, + "Actual Total Time": 119.28, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 10)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 85, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.161, + "Triggers": [], + "Execution Time": 119.536 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.34, + "Total Cost": 4304.47, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 104.631, + "Actual Total Time": 104.634, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4303.73, + "Total Cost": 4304.5, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 104.616, + "Actual Total Time": 104.624, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 308, + "Plan Width": 152, + "Actual Startup Time": 80.167, + "Actual Total Time": 104.393, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 10)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 87, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.037, + "Triggers": [], + "Execution Time": 104.717 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.481, + "Actual Total Time": 134.487, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.478, + "Actual Total Time": 134.482, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 123.308, + "Actual Total Time": 134.405, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 89, + "Shared Read Blocks": 34, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.124, + "Triggers": [], + "Execution Time": 134.544 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 124.355, + "Actual Total Time": 124.36, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 124.353, + "Actual Total Time": 124.355, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 118.992, + "Actual Total Time": 124.288, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.641, + "Triggers": [], + "Execution Time": 124.411 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 149.216, + "Actual Total Time": 149.22, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 149.214, + "Actual Total Time": 149.215, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 143.262, + "Actual Total Time": 149.151, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 4.527, + "Triggers": [], + "Execution Time": 149.269 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 164.471, + "Actual Total Time": 164.476, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 164.469, + "Actual Total Time": 164.471, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 157.699, + "Actual Total Time": 164.409, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.035, + "Triggers": [], + "Execution Time": 164.544 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.461, + "Actual Total Time": 134.466, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.459, + "Actual Total Time": 134.462, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 128.211, + "Actual Total Time": 134.4, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.284, + "Triggers": [], + "Execution Time": 134.514 + } + ] + } + }, + "100": { + "rows": 306, + "offset": 244, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.73, + "Total Cost": 4304.85, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 133.209, + "Actual Total Time": 133.213, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.12, + "Total Cost": 4304.91, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 133.194, + "Actual Total Time": 133.203, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 93.169, + "Actual Total Time": 132.956, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 100)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 8.122, + "Triggers": [], + "Execution Time": 133.253 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.73, + "Total Cost": 4304.85, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 179.521, + "Actual Total Time": 179.524, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.12, + "Total Cost": 4304.91, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 179.506, + "Actual Total Time": 179.515, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 130.804, + "Actual Total Time": 179.12, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 100)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 8.774, + "Triggers": [], + "Execution Time": 179.569 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.73, + "Total Cost": 4304.85, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 125.632, + "Actual Total Time": 125.635, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.12, + "Total Cost": 4304.91, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 125.618, + "Actual Total Time": 125.627, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 91.07, + "Actual Total Time": 125.392, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 100)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 86, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.155, + "Triggers": [], + "Execution Time": 125.676 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.73, + "Total Cost": 4304.85, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 124.7, + "Actual Total Time": 124.704, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.12, + "Total Cost": 4304.91, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 124.683, + "Actual Total Time": 124.695, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 94.537, + "Actual Total Time": 124.479, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 100)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 85, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.313, + "Triggers": [], + "Execution Time": 124.743 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.73, + "Total Cost": 4304.85, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 120.341, + "Actual Total Time": 120.352, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4304.12, + "Total Cost": 4304.91, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 120.283, + "Actual Total Time": 120.33, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 103, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4291.0, + "Plan Rows": 316, + "Plan Width": 152, + "Actual Startup Time": 87.053, + "Actual Total Time": 119.961, + "Actual Rows": 306.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "(chat_id = 100)", + "Rows Removed by Filter": 119694, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 87, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.379, + "Triggers": [], + "Execution Time": 120.488 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 129.026, + "Actual Total Time": 129.032, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 129.02, + "Actual Total Time": 129.022, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 122.196, + "Actual Total Time": 128.899, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.429, + "Triggers": [], + "Execution Time": 129.158 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.291, + "Actual Total Time": 134.294, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 134.288, + "Actual Total Time": 134.29, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 129.805, + "Actual Total Time": 134.227, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.199, + "Triggers": [], + "Execution Time": 134.347 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 112.116, + "Actual Total Time": 112.121, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 112.113, + "Actual Total Time": 112.116, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 106.824, + "Actual Total Time": 112.045, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.152, + "Triggers": [], + "Execution Time": 112.172 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 136.31, + "Actual Total Time": 136.314, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 136.306, + "Actual Total Time": 136.308, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 131.91, + "Actual Total Time": 136.211, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.27, + "Triggers": [], + "Execution Time": 136.458 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 118.578, + "Actual Total Time": 118.59, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 4891.32, + "Total Cost": 4891.36, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 118.576, + "Actual Total Time": 118.583, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "quicksort", + "Sort Space Used": 40, + "Sort Space Type": "Memory", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Seq Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 4891.0, + "Plan Rows": 16, + "Plan Width": 152, + "Actual Startup Time": 111.341, + "Actual Total Time": 118.467, + "Actual Rows": 62.0, + "Actual Loops": 1, + "Disabled": false, + "Filter": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Filter": 119938, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 2791, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 88, + "Shared Read Blocks": 35, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.557, + "Triggers": [], + "Execution Time": 118.673 + } + ] + } + } + }, + "write": [ + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 18.127, + "Actual Total Time": 18.128, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6115, + "Shared Read Blocks": 17, + "Shared Dirtied Blocks": 57, + "Shared Written Blocks": 61, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 4006, + "WAL FPI": 0, + "WAL Bytes": 554560, + "WAL Buffers Full": 56, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.224, + "Actual Total Time": 2.785, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.222, + "Actual Total Time": 2.596, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.14, + "Triggers": [], + "Execution Time": 18.217 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 15.935, + "Actual Total Time": 15.935, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 7973, + "Shared Read Blocks": 74, + "Shared Dirtied Blocks": 103, + "Shared Written Blocks": 106, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 4039, + "WAL FPI": 0, + "WAL Bytes": 555665, + "WAL Buffers Full": 49, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.201, + "Actual Total Time": 2.456, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.2, + "Actual Total Time": 2.309, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 1, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.153, + "Triggers": [], + "Execution Time": 16.018 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 16.374, + "Actual Total Time": 16.374, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 8049, + "Shared Read Blocks": 78, + "Shared Dirtied Blocks": 103, + "Shared Written Blocks": 107, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 4043, + "WAL FPI": 0, + "WAL Bytes": 556073, + "WAL Buffers Full": 49, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.204, + "Actual Total Time": 2.343, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.202, + "Actual Total Time": 2.199, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 1, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.135, + "Triggers": [], + "Execution Time": 16.468 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 17.205, + "Actual Total Time": 17.206, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 8022, + "Shared Read Blocks": 87, + "Shared Dirtied Blocks": 103, + "Shared Written Blocks": 113, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 4045, + "WAL FPI": 0, + "WAL Bytes": 556895, + "WAL Buffers Full": 50, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.209, + "Actual Total Time": 2.159, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.207, + "Actual Total Time": 2.028, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 1, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.206, + "Triggers": [], + "Execution Time": 17.299 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 15.287, + "Actual Total Time": 15.288, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 8049, + "Shared Read Blocks": 78, + "Shared Dirtied Blocks": 103, + "Shared Written Blocks": 106, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 4043, + "WAL FPI": 0, + "WAL Bytes": 556073, + "WAL Buffers Full": 49, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.206, + "Actual Total Time": 2.128, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.204, + "Actual Total Time": 1.999, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.141, + "Triggers": [], + "Execution Time": 15.376 + } + ] + }, + "composite_index": { + "read": { + "1": { + "rows": 72000, + "offset": 57600, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 7341.39, + "Total Cost": 7347.76, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 12.867, + "Actual Total Time": 12.876, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 9189.37, + "Plan Rows": 72100, + "Plan Width": 152, + "Actual Startup Time": 0.044, + "Actual Total Time": 11.724, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 1)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.675, + "Triggers": [], + "Execution Time": 12.911 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 7341.39, + "Total Cost": 7347.76, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 13.515, + "Actual Total Time": 13.524, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 9189.37, + "Plan Rows": 72100, + "Plan Width": 152, + "Actual Startup Time": 0.04, + "Actual Total Time": 12.354, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 1)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.92, + "Triggers": [], + "Execution Time": 13.555 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 7341.39, + "Total Cost": 7347.76, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 14.132, + "Actual Total Time": 14.141, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 9189.37, + "Plan Rows": 72100, + "Plan Width": 152, + "Actual Startup Time": 0.04, + "Actual Total Time": 12.921, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 1)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.943, + "Triggers": [], + "Execution Time": 14.172 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 7341.39, + "Total Cost": 7347.76, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 12.942, + "Actual Total Time": 12.951, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 9189.37, + "Plan Rows": 72100, + "Plan Width": 152, + "Actual Startup Time": 0.043, + "Actual Total Time": 11.819, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 1)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.46, + "Triggers": [], + "Execution Time": 12.985 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 7341.39, + "Total Cost": 7347.76, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 13.363, + "Actual Total Time": 13.372, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 9189.37, + "Plan Rows": 72100, + "Plan Width": 152, + "Actual Startup Time": 0.042, + "Actual Total Time": 12.229, + "Actual Rows": 57650.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 1)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 1627, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.562, + "Triggers": [], + "Execution Time": 13.403 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 10.45, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.035, + "Actual Total Time": 0.044, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 7512.17, + "Plan Rows": 37435, + "Plan Width": 152, + "Actual Startup Time": 0.033, + "Actual Total Time": 0.041, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.88, + "Triggers": [], + "Execution Time": 0.093 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 10.45, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.048, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 7512.17, + "Plan Rows": 37435, + "Plan Width": 152, + "Actual Startup Time": 0.036, + "Actual Total Time": 0.044, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.584, + "Triggers": [], + "Execution Time": 0.087 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 10.45, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.036, + "Actual Total Time": 0.045, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 7512.17, + "Plan Rows": 37435, + "Plan Width": 152, + "Actual Startup Time": 0.034, + "Actual Total Time": 0.042, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.488, + "Triggers": [], + "Execution Time": 0.083 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 10.45, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.041, + "Actual Total Time": 0.052, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 7512.17, + "Plan Rows": 37435, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 0.048, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.199, + "Triggers": [], + "Execution Time": 0.092 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 10.45, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.052, + "Actual Total Time": 0.067, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 7512.17, + "Plan Rows": 37435, + "Plan Width": 152, + "Actual Startup Time": 0.049, + "Actual Total Time": 0.062, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 1) AND (ROW(created_at, id) > ROW('2025-01-01 03:00:57.6+03'::timestamp with time zone, 57600)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.938, + "Triggers": [], + "Execution Time": 0.12 + } + ] + } + }, + "2": { + "rows": 18000, + "offset": 14400, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5065.38, + "Total Cost": 5065.5, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 21.767, + "Actual Total Time": 21.772, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5029.38, + "Total Cost": 5074.59, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 20.718, + "Actual Total Time": 21.484, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Heap Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 500.57, + "Total Cost": 3750.62, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 0.873, + "Actual Total Time": 14.339, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Recheck Cond": "(chat_id = 2)", + "Rows Removed by Index Recheck": 0, + "Exact Heap Blocks": 420, + "Lossy Heap Blocks": 0, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Index Name": "history_page", + "Startup Cost": 0.0, + "Total Cost": 496.05, + "Plan Rows": 18084, + "Plan Width": 0, + "Actual Startup Time": 0.757, + "Actual Total Time": 0.757, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 2)", + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 92, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.239, + "Triggers": [], + "Execution Time": 27.807 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5065.38, + "Total Cost": 5065.5, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 22.849, + "Actual Total Time": 22.854, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 5, + "Shared Read Blocks": 513, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5029.38, + "Total Cost": 5074.59, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 21.807, + "Actual Total Time": 22.562, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 5, + "Shared Read Blocks": 513, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Heap Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 500.57, + "Total Cost": 3750.62, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 0.985, + "Actual Total Time": 15.927, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Recheck Cond": "(chat_id = 2)", + "Rows Removed by Index Recheck": 0, + "Exact Heap Blocks": 420, + "Lossy Heap Blocks": 0, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Index Name": "history_page", + "Startup Cost": 0.0, + "Total Cost": 496.05, + "Plan Rows": 18084, + "Plan Width": 0, + "Actual Startup Time": 0.842, + "Actual Total Time": 0.842, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 2)", + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 92, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.448, + "Triggers": [], + "Execution Time": 29.379 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5065.38, + "Total Cost": 5065.5, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 21.307, + "Actual Total Time": 21.312, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5029.38, + "Total Cost": 5074.59, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 20.182, + "Actual Total Time": 21.012, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Heap Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 500.57, + "Total Cost": 3750.62, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 0.843, + "Actual Total Time": 13.786, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Recheck Cond": "(chat_id = 2)", + "Rows Removed by Index Recheck": 0, + "Exact Heap Blocks": 420, + "Lossy Heap Blocks": 0, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Index Name": "history_page", + "Startup Cost": 0.0, + "Total Cost": 496.05, + "Plan Rows": 18084, + "Plan Width": 0, + "Actual Startup Time": 0.712, + "Actual Total Time": 0.712, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 2)", + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 92, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.185, + "Triggers": [], + "Execution Time": 34.784 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5065.38, + "Total Cost": 5065.5, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 20.957, + "Actual Total Time": 20.962, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 5, + "Shared Read Blocks": 513, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5029.38, + "Total Cost": 5074.59, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 19.778, + "Actual Total Time": 20.675, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 5, + "Shared Read Blocks": 513, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Heap Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 500.57, + "Total Cost": 3750.62, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 0.856, + "Actual Total Time": 13.712, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Recheck Cond": "(chat_id = 2)", + "Rows Removed by Index Recheck": 0, + "Exact Heap Blocks": 420, + "Lossy Heap Blocks": 0, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Index Name": "history_page", + "Startup Cost": 0.0, + "Total Cost": 496.05, + "Plan Rows": 18084, + "Plan Width": 0, + "Actual Startup Time": 0.679, + "Actual Total Time": 0.679, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 2)", + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 92, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.025, + "Triggers": [], + "Execution Time": 31.21 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5065.38, + "Total Cost": 5065.5, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 21.401, + "Actual Total Time": 21.407, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Sort", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 5029.38, + "Total Cost": 5074.59, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 20.353, + "Actual Total Time": 21.122, + "Actual Rows": 14450.0, + "Actual Loops": 1, + "Disabled": false, + "Sort Key": [ + "created_at", + "id" + ], + "Sort Method": "external merge", + "Sort Space Used": 2928, + "Sort Space Type": "Disk", + "Shared Hit Blocks": 6, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 366, + "Temp Written Blocks": 367, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Heap Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 500.57, + "Total Cost": 3750.62, + "Plan Rows": 18084, + "Plan Width": 152, + "Actual Startup Time": 0.894, + "Actual Total Time": 14.22, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Recheck Cond": "(chat_id = 2)", + "Rows Removed by Index Recheck": 0, + "Exact Heap Blocks": 420, + "Lossy Heap Blocks": 0, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 512, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Bitmap Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Index Name": "history_page", + "Startup Cost": 0.0, + "Total Cost": 496.05, + "Plan Rows": 18084, + "Plan Width": 0, + "Actual Startup Time": 0.763, + "Actual Total Time": 0.763, + "Actual Rows": 18000.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 2)", + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 92, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 115, + "Shared Read Blocks": 39, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.44, + "Triggers": [], + "Execution Time": 29.46 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 52.83, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.041, + "Actual Total Time": 0.05, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 5259.25, + "Plan Rows": 5017, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 0.046, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.319, + "Triggers": [], + "Execution Time": 0.09 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 52.83, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 0.057, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 5259.25, + "Plan Rows": 5017, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.054, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.86, + "Triggers": [], + "Execution Time": 0.101 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 52.83, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.048, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 5259.25, + "Plan Rows": 5017, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.044, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.939, + "Triggers": [], + "Execution Time": 0.088 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 52.83, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.04, + "Actual Total Time": 0.05, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 5259.25, + "Plan Rows": 5017, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.046, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.874, + "Triggers": [], + "Execution Time": 0.096 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 52.83, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 0.041, + "Actual Total Time": 0.05, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 5259.25, + "Plan Rows": 5017, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 0.046, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 2) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:26.4+03'::timestamp with time zone, 86400)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 5, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.664, + "Triggers": [], + "Execution Time": 0.096 + } + ] + } + }, + "10": { + "rows": 306, + "offset": 244, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 442.48, + "Total Cost": 493.21, + "Plan Rows": 28, + "Plan Width": 152, + "Actual Startup Time": 1.304, + "Actual Total Time": 1.554, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 493.21, + "Plan Rows": 272, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 1.543, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 10)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.826, + "Triggers": [], + "Execution Time": 1.586 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 442.48, + "Total Cost": 493.21, + "Plan Rows": 28, + "Plan Width": 152, + "Actual Startup Time": 1.255, + "Actual Total Time": 1.49, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 493.21, + "Plan Rows": 272, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 1.48, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 10)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.919, + "Triggers": [], + "Execution Time": 1.522 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 442.48, + "Total Cost": 493.21, + "Plan Rows": 28, + "Plan Width": 152, + "Actual Startup Time": 1.279, + "Actual Total Time": 1.512, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 493.21, + "Plan Rows": 272, + "Plan Width": 152, + "Actual Startup Time": 0.041, + "Actual Total Time": 1.498, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 10)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.94, + "Triggers": [], + "Execution Time": 1.546 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 442.48, + "Total Cost": 493.21, + "Plan Rows": 28, + "Plan Width": 152, + "Actual Startup Time": 1.484, + "Actual Total Time": 1.723, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 493.21, + "Plan Rows": 272, + "Plan Width": 152, + "Actual Startup Time": 0.044, + "Actual Total Time": 1.711, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 10)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.902, + "Triggers": [], + "Execution Time": 1.759 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 442.48, + "Total Cost": 493.21, + "Plan Rows": 28, + "Plan Width": 152, + "Actual Startup Time": 1.653, + "Actual Total Time": 2.157, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 493.21, + "Plan Rows": 272, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 2.143, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 10)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.648, + "Triggers": [], + "Execution Time": 2.203 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.245, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.035, + "Actual Total Time": 0.241, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.294, + "Triggers": [], + "Execution Time": 0.283 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 0.257, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.253, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.162, + "Triggers": [], + "Execution Time": 0.298 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.04, + "Actual Total Time": 0.255, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.25, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 8.005, + "Triggers": [], + "Execution Time": 0.297 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.251, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.036, + "Actual Total Time": 0.246, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.669, + "Triggers": [], + "Execution Time": 0.292 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.094, + "Actual Total Time": 0.346, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 32.34, + "Plan Rows": 14, + "Plan Width": 152, + "Actual Startup Time": 0.087, + "Actual Total Time": 0.337, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 10) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.883+03'::timestamp with time zone, 113883)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 53, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.848, + "Triggers": [], + "Execution Time": 0.462 + } + ] + } + }, + "100": { + "rows": 306, + "offset": 244, + "execution": { + "offset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 436.32, + "Total Cost": 525.65, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 1.28, + "Actual Total Time": 1.554, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 593.54, + "Plan Rows": 332, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 1.543, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 100)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.188, + "Triggers": [], + "Execution Time": 1.601 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 436.32, + "Total Cost": 525.65, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 1.291, + "Actual Total Time": 1.53, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 593.54, + "Plan Rows": 332, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 1.518, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 100)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.427, + "Triggers": [], + "Execution Time": 1.561 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 436.32, + "Total Cost": 525.65, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 1.812, + "Actual Total Time": 2.086, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 593.54, + "Plan Rows": 332, + "Plan Width": 152, + "Actual Startup Time": 0.036, + "Actual Total Time": 2.07, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 100)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 5.557, + "Triggers": [], + "Execution Time": 2.121 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 436.32, + "Total Cost": 525.65, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 1.29, + "Actual Total Time": 1.529, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 593.54, + "Plan Rows": 332, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 1.519, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 100)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.715, + "Triggers": [], + "Execution Time": 1.564 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 436.32, + "Total Cost": 525.65, + "Plan Rows": 50, + "Plan Width": 152, + "Actual Startup Time": 1.284, + "Actual Total Time": 1.523, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 593.54, + "Plan Rows": 332, + "Plan Width": 152, + "Actual Startup Time": 0.039, + "Actual Total Time": 1.513, + "Actual Rows": 294.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "(chat_id = 100)", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 299, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 38, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.246, + "Triggers": [], + "Execution Time": 1.555 + } + ], + "keyset": [ + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.257, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.036, + "Actual Total Time": 0.253, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.637, + "Triggers": [], + "Execution Time": 0.297 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.078, + "Actual Total Time": 0.561, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.075, + "Actual Total Time": 0.555, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 6.85, + "Triggers": [], + "Execution Time": 0.63 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.042, + "Actual Total Time": 0.265, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.041, + "Actual Total Time": 0.26, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 11.578, + "Triggers": [], + "Execution Time": 0.323 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.102, + "Actual Total Time": 0.35, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.098, + "Actual Total Time": 0.344, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 7.78, + "Triggers": [], + "Execution Time": 0.456 + }, + { + "Plan": { + "Node Type": "Limit", + "Parallel Aware": false, + "Async Capable": false, + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.038, + "Actual Total Time": 0.285, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Index Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Scan Direction": "Forward", + "Index Name": "history_page", + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.42, + "Total Cost": 37.85, + "Plan Rows": 17, + "Plan Width": 152, + "Actual Startup Time": 0.037, + "Actual Total Time": 0.281, + "Actual Rows": 50.0, + "Actual Loops": 1, + "Disabled": false, + "Index Cond": "((chat_id = 100) AND (ROW(created_at, id) > ROW('2025-01-01 03:01:53.875+03'::timestamp with time zone, 113875)))", + "Rows Removed by Index Recheck": 0, + "Index Searches": 1, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 54, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + }, + "Planning": { + "Shared Hit Blocks": 116, + "Shared Read Blocks": 37, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 9.516, + "Triggers": [], + "Execution Time": 0.325 + } + ] + } + } + }, + "write": [ + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 30.086, + "Actual Total Time": 30.087, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 14111, + "Shared Read Blocks": 90, + "Shared Dirtied Blocks": 76, + "Shared Written Blocks": 114, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 6063, + "WAL FPI": 0, + "WAL Bytes": 784089, + "WAL Buffers Full": 76, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.224, + "Actual Total Time": 2.694, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.222, + "Actual Total Time": 2.528, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.144, + "Triggers": [], + "Execution Time": 30.182 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 30.149, + "Actual Total Time": 30.15, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 14109, + "Shared Read Blocks": 84, + "Shared Dirtied Blocks": 124, + "Shared Written Blocks": 142, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 6061, + "WAL FPI": 0, + "WAL Bytes": 783321, + "WAL Buffers Full": 76, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.198, + "Actual Total Time": 3.292, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.197, + "Actual Total Time": 3.068, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.138, + "Triggers": [], + "Execution Time": 30.244 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 29.637, + "Actual Total Time": 29.638, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 14103, + "Shared Read Blocks": 85, + "Shared Dirtied Blocks": 123, + "Shared Written Blocks": 129, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 6061, + "WAL FPI": 0, + "WAL Bytes": 779726, + "WAL Buffers Full": 75, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.202, + "Actual Total Time": 2.563, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.2, + "Actual Total Time": 2.396, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.127, + "Triggers": [], + "Execution Time": 29.723 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 24.04, + "Actual Total Time": 24.041, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 14099, + "Shared Read Blocks": 93, + "Shared Dirtied Blocks": 124, + "Shared Written Blocks": 149, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 6063, + "WAL FPI": 0, + "WAL Bytes": 784113, + "WAL Buffers Full": 72, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.195, + "Actual Total Time": 2.514, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.193, + "Actual Total Time": 2.372, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.129, + "Triggers": [], + "Execution Time": 24.125 + }, + { + "Plan": { + "Node Type": "ModifyTable", + "Operation": "Insert", + "Parallel Aware": false, + "Async Capable": false, + "Relation Name": "history", + "Alias": "history", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 0, + "Plan Width": 0, + "Actual Startup Time": 25.341, + "Actual Total Time": 25.343, + "Actual Rows": 0.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 14107, + "Shared Read Blocks": 85, + "Shared Dirtied Blocks": 127, + "Shared Written Blocks": 137, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 6063, + "WAL FPI": 0, + "WAL Bytes": 787078, + "WAL Buffers Full": 72, + "Plans": [ + { + "Node Type": "Subquery Scan", + "Parent Relationship": "Outer", + "Parallel Aware": false, + "Async Capable": false, + "Alias": "*SELECT*", + "Startup Cost": 0.0, + "Total Cost": 55.0, + "Plan Rows": 2000, + "Plan Width": 52, + "Actual Startup Time": 0.202, + "Actual Total Time": 2.81, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0, + "Plans": [ + { + "Node Type": "Function Scan", + "Parent Relationship": "Subquery", + "Parallel Aware": false, + "Async Capable": false, + "Function Name": "generate_series", + "Alias": "n", + "Startup Cost": 0.0, + "Total Cost": 50.0, + "Plan Rows": 2000, + "Plan Width": 48, + "Actual Startup Time": 0.2, + "Actual Total Time": 2.611, + "Actual Rows": 2000.0, + "Actual Loops": 1, + "Disabled": false, + "Shared Hit Blocks": 0, + "Shared Read Blocks": 0, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 0, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0, + "WAL Records": 0, + "WAL FPI": 0, + "WAL Bytes": 0, + "WAL Buffers Full": 0 + } + ] + } + ] + }, + "Planning": { + "Shared Hit Blocks": 5, + "Shared Read Blocks": 1, + "Shared Dirtied Blocks": 0, + "Shared Written Blocks": 1, + "Local Hit Blocks": 0, + "Local Read Blocks": 0, + "Local Dirtied Blocks": 0, + "Local Written Blocks": 0, + "Temp Read Blocks": 0, + "Temp Written Blocks": 0 + }, + "Planning Time": 0.14, + "Triggers": [], + "Execution Time": 25.442 + } + ] + }, + "backup": { + "backup_ms": 654.77, + "restore_ms": 925.997, + "bytes": 3477911, + "same_counts_and_samples": true, + "snapshot": { + "per_chat": [ + "1|72000", + "2|18000", + "3|306", + "4|306", + "5|306", + "6|306", + "7|306", + "8|306", + "9|306", + "10|306", + "11|306", + "12|306", + "13|306", + "14|306", + "15|306", + "16|306", + "17|306", + "18|306", + "19|306", + "20|306", + "21|306", + "22|306", + "23|306", + "24|306", + "25|306", + "26|306", + "27|306", + "28|306", + "29|306", + "30|306", + "31|306", + "32|306", + "33|306", + "34|306", + "35|306", + "36|306", + "37|306", + "38|306", + "39|306", + "40|307", + "41|307", + "42|307", + "43|307", + "44|307", + "45|307", + "46|307", + "47|307", + "48|307", + "49|307", + "50|307", + "51|307", + "52|306", + "53|306", + "54|306", + "55|306", + "56|306", + "57|306", + "58|306", + "59|306", + "60|306", + "61|306", + "62|306", + "63|306", + "64|306", + "65|306", + "66|306", + "67|306", + "68|306", + "69|306", + "70|306", + "71|306", + "72|306", + "73|306", + "74|306", + "75|306", + "76|306", + "77|306", + "78|306", + "79|306", + "80|306", + "81|306", + "82|306", + "83|306", + "84|306", + "85|306", + "86|306", + "87|306", + "88|306", + "89|306", + "90|306", + "91|306", + "92|306", + "93|306", + "94|306", + "95|306", + "96|306", + "97|306", + "98|306", + "99|306", + "100|306" + ], + "sample_rows": [ + "1|1|f50b1b079f973515641e32f5b8a8e297", + "50001|1|487e851d4218144584cdee174d182ec8", + "119999|50|f1090858c41e395b5511272aad473463", + "120000|51|9fa49012104931863896da71a1c278ee" + ], + "count": 120000 + }, + "post_backup_marker_restored": false, + "source_rows_after_marker": 120001 + }, + "environment": "Native Windows isolated PostgreSQL 18.0, no Docker" +} diff --git a/evidence/local-checks.txt b/evidence/local-checks.txt new file mode 100644 index 00000000..69733d70 --- /dev/null +++ b/evidence/local-checks.txt @@ -0,0 +1,3 @@ +PASS: public lab2 API smoke on native PostgreSQL 18.0 with a test double for Redis. +PASS: native PostgreSQL snapshot restored 120000 rows and selected checksums matched. See history-windows.json. +Docker Compose persistence and dependency-stop checks remain pending. diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..fb964d90 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +psycopg[binary]==3.2.13 +psycopg-pool==3.2.8 +redis==6.4.0 diff --git a/scripts/bootstrap.py b/scripts/bootstrap.py new file mode 100644 index 00000000..eaadd8ba --- /dev/null +++ b/scripts/bootstrap.py @@ -0,0 +1,37 @@ +"""Create local credentials once. Run from the repository on Windows or Linux.""" + +from pathlib import Path +from secrets import token_hex + + +ROOT = Path(__file__).resolve().parent.parent +LOCAL = ROOT / "secrets" + + +def keep(path, value): + try: + with path.open("x", encoding="utf-8", newline="\n") as stream: + stream.write(value + "\n") + except FileExistsError: + pass + return path.read_text(encoding="utf-8").strip() + + +def main(): + LOCAL.mkdir(mode=0o700, exist_ok=True) + db = keep(LOCAL / "db_password", token_hex(24)) + cache = keep(LOCAL / "cache_password", token_hex(24)) + keep(LOCAL / "database_url", f"postgresql://messenger:{db}@db:5432/messenger") + keep(LOCAL / "cache_url", f"redis://:{cache}@cache:6379/0") + keep(LOCAL / "cursor_key", token_hex(32)) + keep(LOCAL / "redis.conf", "\n".join(( + "bind 0.0.0.0", "protected-mode yes", "dir /data", + "appendonly yes", "appendfsync always", "maxmemory 64mb", + "maxmemory-policy noeviction", f"requirepass {cache}", + ))) + keep(ROOT / ".env", "HTTP_PORT=8080\nSESSION_TTL_SECONDS=3600") + print("Локальная конфигурация готова.") + + +if __name__ == "__main__": + main() diff --git a/scripts/history_experiment.py b/scripts/history_experiment.py new file mode 100644 index 00000000..f864d952 --- /dev/null +++ b/scripts/history_experiment.py @@ -0,0 +1,156 @@ +"""Compare keyset and OFFSET on uneven histories, then verify a logical restore.""" + +import argparse +import json +import math +import shlex +import subprocess +import time +from pathlib import Path +from uuid import uuid4 + + +ROOT = Path(__file__).resolve().parents[1] +SAMPLE_CHATS = (1, 2, 10, 100) +SAMPLE_ROWS = (1, 50001, 119999, 120000) +REPEATS = 5 + + +def db(*args, content=None): + result = subprocess.run( + ["docker", "compose", "exec", "-T", "db", *args], + cwd=ROOT, input=content, capture_output=True, check=True, timeout=90, + ) + return result.stdout + + +def sql(database, text): + return db("psql", "-X", "-qAt", "-v", "ON_ERROR_STOP=1", "-U", "messenger", + "-d", database, content=text.encode()).decode().strip() + + +def explain(database, statement): + plan = sql(database, "EXPLAIN (ANALYZE, BUFFERS, WAL, FORMAT JSON) " + statement) + return json.loads(plan)[0] + + +def time_call(action): + started = time.perf_counter() + value = action() + return value, round(1000 * (time.perf_counter() - started), 3) + + +def signature(database): + groups = sql(database, "SELECT chat_id, count(*) FROM history GROUP BY 1 ORDER BY 1;") + ids = ",".join(map(str, SAMPLE_ROWS)) + rows = sql(database, f"SELECT id, chat_id, md5(body) FROM history WHERE id IN ({ids}) ORDER BY id;") + return {"per_chat": groups.splitlines(), "sample_rows": rows.splitlines(), + "count": int(sql(database, "SELECT count(*) FROM history;"))} + + +def seed(database): + sql(database, """ + CREATE TABLE history ( + id bigint PRIMARY KEY, chat_id int NOT NULL, + created_at timestamptz NOT NULL, body text NOT NULL + ); + INSERT INTO history + SELECT n, + CASE WHEN n <= 72000 THEN 1 WHEN n <= 90000 THEN 2 ELSE 3 + n % 98 END, + timestamptz '2025-01-01T00:00:00Z' + n * interval '1 millisecond', + repeat(md5(n::text), 4) + FROM generate_series(1,120000) AS n; + ANALYZE history; + """) + + +def sample_plan(database, statement): + explain(database, statement) + return [explain(database, statement) for _ in range(REPEATS)] + + +def read_bench(database): + measurements = {} + for chat_id in SAMPLE_CHATS: + order = "ORDER BY created_at, id" + where = f"FROM history WHERE chat_id = {chat_id}" + count = int(sql(database, f"SELECT count(*) {where};")) + offset = max(1, math.floor(count * 0.8)) + timestamp, position = sql( + database, f"SELECT created_at, id {where} {order} OFFSET {offset - 1} LIMIT 1;" + ).split("|") + seek = f"AND (created_at,id) > ('{timestamp}'::timestamptz,{int(position)})" + statements = { + "offset": f"SELECT * {where} {order} OFFSET {offset} LIMIT 50;", + "keyset": f"SELECT * {where} {seek} {order} LIMIT 50;", + } + if sql(database, statements["offset"]) != sql(database, statements["keyset"]): + raise AssertionError("offset and keyset differ on an unchanged history") + measurements[str(chat_id)] = {"rows": count, "offset": offset, "execution": { + name: sample_plan(database, statement) for name, statement in statements.items() + }} + return measurements + + +def write_bench(database): + # Roll back so all measurements use exactly the same logical data. + statement = """ + BEGIN; + EXPLAIN (ANALYZE, BUFFERS, WAL, FORMAT JSON) + INSERT INTO history + SELECT 120000+n, 1, clock_timestamp(), repeat(md5(n::text),4) + FROM generate_series(1,2000) n; + ROLLBACK; + """ + return [json.loads(sql(database, statement))[0] for _ in range(REPEATS)] + + +def run(): + suffix = uuid4().hex[:10] + source, target = f"hist_lab2_{suffix}", f"restore_lab2_{suffix}" + created = [] + try: + for database in (source, target): + db("createdb", "-U", "messenger", database) + created.append(database) + seed(source) + baseline = {"read": read_bench(source), "write": write_bench(source)} + sql(source, "CREATE INDEX history_page ON history(chat_id, created_at, id); ANALYZE history;") + indexed = {"read": read_bench(source), "write": write_bench(source)} + original = signature(source) + dump, backup_ms = time_call(lambda: db("pg_dump", "-U", "messenger", "-Fc", source)) + sql(source, "INSERT INTO history VALUES (120001,1,clock_timestamp(),'post-backup marker');") + _, restore_ms = time_call(lambda: db( + "pg_restore", "--exit-on-error", "-U", "messenger", "-d", target, content=dump + )) + restored = signature(target) + if original != restored or int(sql(target, "SELECT count(*) FROM history WHERE id=120001;")) != 0: + raise AssertionError("restore differs from the backup snapshot") + return { + "hypothesis": "Composite index bounds keyset read work at the cost of extra write I/O", + "server": sql(source, "SHOW server_version;"), "repeat_count": REPEATS, + "baseline_primary_key_only": baseline, "composite_index": indexed, + "backup": {"backup_ms": backup_ms, "restore_ms": restore_ms, "bytes": len(dump), + "same_counts_and_samples": True, "snapshot": restored, + "post_backup_marker_restored": False, + "source_rows_after_marker": signature(source)["count"]}, + } + finally: + for database in reversed(created): + db("dropdb", "-U", "messenger", database) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--output", type=Path, default=ROOT / "evidence" / "history-experiment.json") + args = parser.parse_args() + try: + result = run() + except subprocess.CalledProcessError as exc: + raise SystemExit(f"Failed: {shlex.join(exc.cmd[3:])}\n{exc.stderr.decode(errors='replace')}") from None + args.output.write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8") + print(f"Observed {result['backup']['snapshot']['count']} restored rows. Raw plans: {args.output}") + + +if __name__ == "__main__": + main() diff --git a/scripts/restart.cmd b/scripts/restart.cmd new file mode 100644 index 00000000..1eaecf1d --- /dev/null +++ b/scripts/restart.cmd @@ -0,0 +1,6 @@ +@echo off +cd /d "%~dp0.." +docker compose ps api db cache || exit /b 1 +docker compose restart db cache || exit /b 1 +docker compose restart api || exit /b 1 +docker compose ps api db cache diff --git a/scripts/restart.sh b/scripts/restart.sh new file mode 100755 index 00000000..72b4dd18 --- /dev/null +++ b/scripts/restart.sh @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu +cd "$(dirname "$0")/.." +docker compose ps api db cache +docker compose restart db cache +docker compose restart api +docker compose ps api db cache diff --git a/src/app.py b/src/app.py new file mode 100644 index 00000000..93903d47 --- /dev/null +++ b/src/app.py @@ -0,0 +1,409 @@ +"""HTTP entry point for the persistent messenger (based on lab 1).""" + +import base64 +import datetime as dt +import hashlib +import hmac +import json +import os +import re +import signal +import threading +import time +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from urllib.parse import parse_qs, urlsplit +from uuid import UUID, uuid4 + +import psycopg +from psycopg_pool import PoolTimeout +from redis.exceptions import RedisError + +from auth import Sessions, USERNAME, parse_basic, parse_bearer, password_hash, valid_password, verify_password +from db import Store, setting + + +MAX_BODY = 64 * 1024 +QUERY_LIMIT = re.compile(r"[0-9]{1,6}") +LENGTH = re.compile(r"[0-9]{1,12}") +FIRST = (dt.datetime.min.replace(tzinfo=dt.timezone.utc), UUID(int=0)) + + +class ApiError(Exception): + def __init__(self, status, code, message, headers=None): + super().__init__(message) + self.status, self.code, self.message = status, code, message + self.headers = headers or {} + + +def bad(message="Некорректный запрос"): + return ApiError(400, "invalid_request", message) + + +def not_found(): + return ApiError(404, "not_found", "Объект не найден") + + +def unauthorized(scheme): + challenge = f'{scheme} realm="messenger"' + if scheme == "Basic": + challenge += ', charset="UTF-8"' + return ApiError(401, "unauthorized", "Нужна аутентификация", {"WWW-Authenticate": challenge}) + + +def clean_text(value, min_len, max_len, field): + if not isinstance(value, str) or not min_len <= len(value) <= max_len or not value.strip(): + raise bad(f"Поле {field} имеет недопустимую длину или тип") + try: + value.encode("utf-8") + except UnicodeEncodeError: + raise bad(f"Поле {field} содержит недопустимые символы") + if "\x00" in value: + raise bad(f"Поле {field} содержит NUL") + return value + + +def parse_uuid(value): + if not isinstance(value, str): + raise bad("Некорректный UUID") + try: + return UUID(value) + except ValueError: + raise bad("Некорректный UUID") + + +def only_fields(body, required, optional=()): + if not isinstance(body, dict) or set(required) - body.keys() or body.keys() - set(required + optional): + raise bad("Неверный набор полей") + + +def json_value(value): + if isinstance(value, dt.datetime): + return value.astimezone(dt.timezone.utc).isoformat().replace("+00:00", "Z") + if isinstance(value, UUID): + return str(value) + raise TypeError("Unsupported JSON value") + + +def encode_cursor(scope, row, key): + raw = json.dumps([scope, row["created_at"], row["id"]], default=json_value).encode() + signature = hmac.digest(key, raw, "sha256") + return base64.urlsafe_b64encode(raw + signature).decode().rstrip("=") + + +def decode_cursor(cursor, scope, key): + try: + if len(cursor) > 512 or not re.fullmatch(r"[A-Za-z0-9_-]+", cursor): + raise ValueError + envelope = base64.urlsafe_b64decode(cursor + "=" * (-len(cursor) % 4)) + raw, signature = envelope[:-32], envelope[-32:] + if not hmac.compare_digest(hmac.digest(key, raw, "sha256"), signature): + raise ValueError + actual_scope, timestamp, item_id = json.loads(raw) + if actual_scope != scope: + raise ValueError + return dt.datetime.fromisoformat(timestamp.replace("Z", "+00:00")), UUID(item_id) + except (ValueError, TypeError, AttributeError): + raise bad("Некорректный cursor") + + +def page(ctx, scope, read): + limit = ctx.param("limit", "50") + cursor = ctx.param("cursor") + if not QUERY_LIMIT.fullmatch(limit) or not 1 <= int(limit) <= 100: + raise bad("limit должен быть целым числом от 1 до 100") + count = int(limit) + key = ctx.server.cursor_key + rows = read(decode_cursor(cursor, scope, key) if cursor is not None else FIRST, count + 1) + return {"items": rows[:count], + "next_cursor": encode_cursor(scope, rows[count - 1], key) if len(rows) > count else None} + + +def create_user(ctx): + body = ctx.json_body() + only_fields(body, ("username", "display_name", "password")) + username = body["username"] + if not isinstance(username, str) or not USERNAME.fullmatch(username): + raise bad("Некорректный username") + name = clean_text(body["display_name"], 1, 100, "display_name") + if not valid_password(body["password"]): + raise bad("Некорректный password") + try: + return 201, ctx.store.register(username, name, password_hash(body["password"])) + except psycopg.errors.UniqueViolation: + raise ApiError(409, "conflict", "Username уже занят") + + +def login(ctx): + if ctx.content_length(): + raise bad("Вход принимает только Basic Authorization") + credentials = parse_basic(ctx.header("Authorization")) + if not credentials: + raise unauthorized("Basic") + username, password = credentials + user, stored = ctx.store.credential(username) + if not verify_password(password, stored): + raise unauthorized("Basic") + token, expires = ctx.server.sessions.issue(user["id"]) + return 201, {"token": token, "token_type": "Bearer", "expires_at": expires, "user": user} + + +def logout(ctx): + if not ctx.server.sessions.revoke(ctx.token): + raise unauthorized("Bearer") + return 204, None + + +def get_me(ctx): + return 200, ctx.user + + +def create_chat(ctx): + body = ctx.json_body() + only_fields(body, ("title", "member_ids")) + title = clean_text(body["title"], 1, 100, "title") + ids = body["member_ids"] + if not isinstance(ids, list) or not 1 <= len(ids) <= 100: + raise bad("member_ids: от 1 до 100 элементов") + members = [parse_uuid(value) for value in ids] + if len(set(members)) != len(members) or ctx.user["id"] not in members: + raise bad("member_ids: дубликаты или нет вызывающего") + try: + return 201, ctx.store.create_chat(title, members) + except psycopg.errors.ForeignKeyViolation: + raise bad("member_ids: неизвестный пользователь") + + +def list_chats(ctx): + user_id = ctx.user["id"] + return 200, page(ctx, f"chats:{user_id}", lambda cursor, n: ctx.store.chats(user_id, cursor, n)) + + +def visible_chat(ctx, chat_id): + chat = ctx.store.chat(ctx.user["id"], parse_uuid(chat_id)) + if chat is None: + raise not_found() + return chat + + +def get_chat(ctx, chat_id): + return 200, visible_chat(ctx, chat_id) + + +def create_message(ctx, chat_id): + chat = visible_chat(ctx, chat_id) + body = ctx.json_body() + only_fields(body, ("text",)) + text = clean_text(body["text"], 1, 4000, "text") + return 201, ctx.store.message(ctx.user["id"], chat["id"], text) + + +def list_messages(ctx, chat_id): + cid = visible_chat(ctx, chat_id)["id"] + return 200, page(ctx, f"messages:{cid}", lambda cursor, n: ctx.store.messages(cid, cursor, n)) + + +def live(ctx): + return 200, {"status": "ok"} + + +def ready(ctx): + if ctx.server.stopping.is_set(): + raise ApiError(503, "unavailable", "Сервер завершает работу") + ctx.store.ready() + ctx.server.sessions.redis.ping() + return live(ctx) + + +ROUTES = [(method, re.compile(path), action, authenticated) for method, path, action, authenticated in ( + ("GET", r"/health/live", live, False), + ("GET", r"/health/ready", ready, False), + ("POST", r"/api/v1/users", create_user, False), + ("POST", r"/api/v1/auth/sessions", login, False), + ("DELETE", r"/api/v1/auth/sessions/current", logout, True), + ("GET", r"/api/v1/users/me", get_me, True), + ("POST", r"/api/v1/chats", create_chat, True), + ("GET", r"/api/v1/chats", list_chats, True), + ("GET", r"/api/v1/chats/([^/]+)", get_chat, True), + ("POST", r"/api/v1/chats/([^/]+)/messages", create_message, True), + ("GET", r"/api/v1/chats/([^/]+)/messages", list_messages, True), +)] + + +class Context: + def __init__(self, handler): + self.handler = handler + self.server = handler.server + self.store = self.server.store + self.user = self.token = None + self.body_read = False + self.route = "unmatched" + + def header(self, name): + values = self.handler.headers.get_all(name, []) + return values[0] if len(values) == 1 else "" + + def param(self, name, default=None): + values = self.query.get(name, []) + if len(values) > 1: + raise bad(f"Повторяющийся параметр {name}") + return values[0] if values else default + + def content_length(self): + if self.handler.headers.get_all("Transfer-Encoding"): + raise bad("Нужен запрос с Content-Length") + if not self.handler.headers.get_all("Content-Length"): + return 0 + value = self.header("Content-Length") + if not LENGTH.fullmatch(value): + raise bad("Некорректный Content-Length") + return int(value) + + def read_body(self, limit): + length = self.content_length() + if length > limit: + raise ApiError(413, "payload_too_large", "Слишком большое тело запроса") + try: + raw = self.handler.rfile.read(length) + except TimeoutError: + raise bad("Таймаут чтения тела") + self.body_read = True + if len(raw) != length: + raise bad("Тело запроса получено не полностью") + return raw + + def json_body(self): + raw = self.read_body(MAX_BODY) + if self.header("Content-Type").split(";")[0].strip().lower() != "application/json": + raise ApiError(415, "unsupported_media_type", "Нужен application/json") + try: + return json.loads(raw.decode("utf-8")) + except (ValueError, RecursionError): + raise bad("Некорректный JSON") + + def authenticate(self): + self.token = parse_bearer(self.header("Authorization")) + if self.token: + user_id = self.server.sessions.get(self.token) + if user_id: + self.user = self.store.user(user_id) + if self.user: + return + raise unauthorized("Bearer") + + +class Handler(BaseHTTPRequestHandler): + protocol_version = "HTTP/1.1" + server_version = "messenger" + sys_version = "" + timeout = 8 + + def log_message(self, *args): + pass + + def dispatch(self, ctx): + try: + parts = urlsplit(self.path) + ctx.query = parse_qs(parts.query, keep_blank_values=True, max_num_fields=32) + except ValueError: + raise bad("Некорректный URL") + for method, pattern, action, authenticated in ROUTES: + if method == self.command and (match := pattern.fullmatch(parts.path)): + ctx.route = action.__name__ + if self.server.stopping.is_set() and action != live: + raise ApiError(503, "unavailable", "Сервер завершает работу") + if authenticated: + ctx.authenticate() + return action(ctx, *match.groups()) + raise not_found() + + def handle_any(self): + started = time.monotonic() + request_id = str(uuid4()) + ctx = Context(self) + headers = {} + error = None + try: + status, payload = self.dispatch(ctx) + except ApiError as exc: + error = exc + except (RedisError, PoolTimeout, psycopg.OperationalError, psycopg.errors.QueryCanceled, + psycopg.errors.LockNotAvailable): + error = ApiError(503, "unavailable", "Хранилище временно недоступно") + except Exception as exc: + print(json.dumps({"request_id": request_id, "exception": type(exc).__name__}), flush=True) + error = ApiError(500, "internal_error", "Внутренняя ошибка") + if error: + status, headers = error.status, error.headers + payload = {"error": {"code": error.code, "message": error.message, "request_id": request_id}} + self.close_connection = True # Rejected bodies are never parsed as a next request. + data = b"" if status == 204 else json.dumps(payload, default=json_value, ensure_ascii=False).encode() + try: + self.send_response(status) + if status != 204: + self.send_header("Content-Type", "application/json; charset=utf-8") + self.send_header("Content-Length", str(len(data))) + self.send_header("X-Request-Id", request_id) + self.send_header("Connection", "close") + for name, value in headers.items(): + self.send_header(name, value) + self.end_headers() + if data: + self.wfile.write(data) + except (OSError, TimeoutError): + pass + print(json.dumps({"method": self.command, "route": ctx.route, "status": status, + "duration_ms": round((time.monotonic() - started) * 1000, 2), + "request_id": request_id}), flush=True) + + do_GET = do_POST = do_PUT = do_PATCH = do_DELETE = handle_any + + +class Server(ThreadingHTTPServer): + request_queue_size = 64 + daemon_threads = False + + def __init__(self, address): + super().__init__(address, Handler) + self.stopping = threading.Event() + self.workers = threading.BoundedSemaphore(16) + self.cursor_key = setting("CURSOR_KEY").encode() + self.store = Store() + self.sessions = Sessions() + + def process_request(self, request, address): + if not self.workers.acquire(blocking=False): + self.shutdown_request(request) + return + try: + super().process_request(request, address) + except BaseException: + self.workers.release() + raise + + def process_request_thread(self, request, address): + try: + super().process_request_thread(request, address) + finally: + self.workers.release() + + +def main(): + address = os.environ.get("APP_HOST", "0.0.0.0"), int(os.environ.get("APP_PORT", "8080")) + with Server(address) as server: + def stop(signum, frame): + if not server.stopping.is_set(): + server.stopping.set() + threading.Thread(target=server.shutdown, daemon=True).start() + + signal.signal(signal.SIGTERM, stop) + signal.signal(signal.SIGINT, stop) + try: + server.serve_forever() + finally: + server.server_close() + server.store.pool.close() + server.sessions.redis.close() + + +if __name__ == "__main__": + main() diff --git a/src/auth.py b/src/auth.py new file mode 100644 index 00000000..79bef16c --- /dev/null +++ b/src/auth.py @@ -0,0 +1,91 @@ +"""Password verification and revocable Redis-backed sessions.""" + +import base64 +import hashlib +import hmac +import os +import re +import secrets +from datetime import datetime, timezone + +from redis import Redis + +from db import setting + + +USERNAME = re.compile(r"[a-z0-9_]{3,32}") +TOKEN = re.compile(r"[A-Za-z0-9_-]{43}") + + +def valid_password(password): + if not isinstance(password, str) or not 12 <= len(password) <= 128: + return False + try: + password.encode("utf-8") + except UnicodeEncodeError: + return False + return True + + +def password_hash(password, salt=None): + if salt is None: + salt = secrets.token_bytes(16) + digest = hashlib.scrypt(password.encode("utf-8"), salt=salt, n=16384, r=8, p=3) + return f"scrypt:{salt.hex()}:{digest.hex()}" + + +DUMMY_HASH = password_hash("dummy unknown account") + + +def verify_password(password, stored): + _, salt, _ = (stored or DUMMY_HASH).split(":") + actual = password_hash(password, bytes.fromhex(salt)) + return hmac.compare_digest(actual, stored or DUMMY_HASH) and stored is not None + + +def parse_basic(value): + scheme, _, data = value.partition(" ") + if scheme.lower() != "basic" or not 1 <= len(data) <= 1024: + return None + try: + username, sep, password = base64.b64decode(data, validate=True).decode("utf-8").partition(":") + except (ValueError, UnicodeError): + return None + if sep and USERNAME.fullmatch(username) and valid_password(password): + return username, password + return None + + +def parse_bearer(value): + scheme, _, token = value.partition(" ") + if scheme.lower() == "bearer" and TOKEN.fullmatch(token): + return token + return None + + +class Sessions: + def __init__(self): + self.redis = Redis.from_url( + setting("CACHE_URL"), socket_timeout=2, socket_connect_timeout=2, + max_connections=24, decode_responses=True, + ) + self.ttl = int(os.environ.get("SESSION_TTL_SECONDS", "3600")) + if self.ttl < 1: + raise ValueError("SESSION_TTL_SECONDS must be positive") + + @staticmethod + def key(token): + return "messenger:session:" + hashlib.sha256(token.encode("ascii")).hexdigest() + + def issue(self, user_id): + token = secrets.token_urlsafe(32) + seconds, micros = self.redis.time() + expires_ms = seconds * 1000 + micros // 1000 + self.ttl * 1000 + self.redis.set(self.key(token), str(user_id), pxat=expires_ms) + return token, datetime.fromtimestamp(expires_ms / 1000, timezone.utc) + + def get(self, token): + return self.redis.get(self.key(token)) + + def revoke(self, token): + return bool(self.redis.delete(self.key(token))) diff --git a/src/db.py b/src/db.py new file mode 100644 index 00000000..2cec8390 --- /dev/null +++ b/src/db.py @@ -0,0 +1,135 @@ +"""PostgreSQL migrations, transactional writes and keyset reads.""" + +import os +from pathlib import Path +from uuid import uuid4 + +import psycopg +from psycopg.conninfo import make_conninfo +from psycopg.rows import dict_row +from psycopg_pool import ConnectionPool + + +def setting(name): + path = os.environ.get(name + "_FILE") + return Path(path).read_text(encoding="utf-8").strip() if path else os.environ[name] + + +def connection_string(): + return make_conninfo( + setting("DATABASE_URL"), + connect_timeout=3, + options="-c statement_timeout=4000 -c lock_timeout=2500", + ) + + +def migrate(): + with psycopg.connect(connection_string(), autocommit=True) as connection: + migrations = Path(__file__).with_name("migrations") + with connection.transaction(): + connection.execute("SELECT pg_advisory_xact_lock(17002026)") + connection.execute(""" + CREATE TABLE IF NOT EXISTS schema_migrations ( + name text PRIMARY KEY, applied_at timestamptz NOT NULL DEFAULT now() + ) + """) + for file in sorted(migrations.glob("*.sql")): + with connection.transaction(): + connection.execute("SELECT pg_advisory_xact_lock(17002026)") + if connection.execute( + "SELECT 1 FROM schema_migrations WHERE name = %s", (file.name,) + ).fetchone(): + continue + connection.execute(file.read_text(encoding="utf-8")) + connection.execute("INSERT INTO schema_migrations(name) VALUES (%s)", (file.name,)) + + +class Store: + def __init__(self): + self.pool = ConnectionPool( + connection_string(), min_size=1, max_size=8, timeout=2, open=False, + kwargs={"row_factory": dict_row}, + ) + self.pool.open() + + def ready(self): + with self.pool.connection() as connection: + connection.execute("SELECT 1") + + def register(self, username, display_name, password_hash): + with self.pool.connection() as connection: + return connection.execute(""" + INSERT INTO users(id, username, display_name, password_hash) + VALUES (%s, %s, %s, %s) + RETURNING id, username, display_name, created_at + """, (uuid4(), username, display_name, password_hash)).fetchone() + + def credential(self, username): + with self.pool.connection() as connection: + user = connection.execute(""" + SELECT id, username, display_name, created_at, password_hash + FROM users WHERE username = %s + """, (username,)).fetchone() + if user: + return user, user.pop("password_hash") + return None, None + + def user(self, user_id): + with self.pool.connection() as connection: + return connection.execute(""" + SELECT id, username, display_name, created_at FROM users WHERE id = %s + """, (user_id,)).fetchone() + + def create_chat(self, title, members): + with self.pool.connection() as connection: + chat = connection.execute(""" + INSERT INTO chats(id, title) VALUES (%s, %s) RETURNING * + """, (uuid4(), title)).fetchone() + connection.execute(""" + INSERT INTO chat_members(chat_id, user_id, position) + SELECT %s, member, ord FROM unnest(%s::uuid[]) WITH ORDINALITY AS m(member, ord) + """, (chat["id"], members)) + return {**chat, "member_ids": members} + + def chat(self, user_id, chat_id): + with self.pool.connection() as connection: + return connection.execute(""" + SELECT c.*, ARRAY(SELECT user_id FROM chat_members m + WHERE m.chat_id = c.id ORDER BY m.position) AS member_ids + FROM chats c JOIN chat_members membership ON membership.chat_id = c.id + WHERE membership.user_id = %s AND c.id = %s + """, (user_id, chat_id)).fetchone() + + def chats(self, user_id, cursor, count): + with self.pool.connection() as connection: + return connection.execute(""" + SELECT c.*, ARRAY(SELECT m.user_id FROM chat_members m + WHERE m.chat_id = c.id ORDER BY m.position) AS member_ids + FROM chats c JOIN chat_members membership ON membership.chat_id = c.id + WHERE membership.user_id = %s + AND (c.created_at, c.id) > (%s::timestamptz, %s::uuid) + ORDER BY c.created_at, c.id LIMIT %s + """, (user_id, *cursor, count)).fetchall() + + def message(self, user_id, chat_id, text): + with self.pool.connection() as connection: + return self.insert_message(connection, user_id, chat_id, text) + + def insert_message(self, connection, user_id, chat_id, text): + return connection.execute(""" + INSERT INTO messages(id, chat_id, sender_id, text) + VALUES (%s, %s, %s, %s) + RETURNING * + """, (uuid4(), chat_id, user_id, text)).fetchone() + + def messages(self, chat_id, cursor, count): + with self.pool.connection() as connection: + return connection.execute(""" + SELECT * FROM messages + WHERE chat_id = %s AND (created_at, id) > (%s::timestamptz, %s::uuid) + ORDER BY created_at, id LIMIT %s + """, (chat_id, *cursor, count)).fetchall() + + +if __name__ == "__main__": + migrate() diff --git a/src/migrations/001_messenger.sql b/src/migrations/001_messenger.sql new file mode 100644 index 00000000..b4b73726 --- /dev/null +++ b/src/migrations/001_messenger.sql @@ -0,0 +1,33 @@ +CREATE TABLE users ( + id uuid PRIMARY KEY, + username text NOT NULL UNIQUE CHECK (username ~ '^[a-z0-9_]{3,32}$'), + display_name text NOT NULL, + password_hash text NOT NULL, + created_at timestamptz NOT NULL DEFAULT clock_timestamp() +); + +CREATE TABLE chats ( + id uuid PRIMARY KEY, + title text NOT NULL, + created_at timestamptz NOT NULL DEFAULT clock_timestamp() +); +CREATE INDEX chats_page ON chats (created_at, id); + +CREATE TABLE chat_members ( + chat_id uuid NOT NULL REFERENCES chats(id), + user_id uuid NOT NULL REFERENCES users(id), + position integer NOT NULL CHECK (position > 0), + PRIMARY KEY (chat_id, user_id), + UNIQUE (chat_id, position) +); +CREATE INDEX chat_members_by_user ON chat_members (user_id, chat_id); + +CREATE TABLE messages ( + id uuid PRIMARY KEY, + chat_id uuid NOT NULL, + sender_id uuid NOT NULL, + text text NOT NULL, + created_at timestamptz NOT NULL DEFAULT clock_timestamp(), + FOREIGN KEY (chat_id, sender_id) REFERENCES chat_members(chat_id, user_id) +); +CREATE INDEX messages_page ON messages (chat_id, created_at, id); diff --git a/student-tests/auth_and_atomicity.py b/student-tests/auth_and_atomicity.py new file mode 100644 index 00000000..1a11fbdc --- /dev/null +++ b/student-tests/auth_and_atomicity.py @@ -0,0 +1,85 @@ +"""Exercise races, transaction rollback, expiry and dependency loss on a test stack.""" + +import argparse +import secrets +import subprocess +import sys +import time +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path +from uuid import uuid4 + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "tests")) +from client import Client, Failure, check # noqa: E402 + + +def compose(*args): + subprocess.run(["docker", "compose", *args], cwd=ROOT, check=True, timeout=80) + + +def await_ready(client): + deadline = time.monotonic() + 35 + while time.monotonic() < deadline: + try: + client.call("GET", "/health/ready", schema="Health") + return + except Failure: + time.sleep(0.5) + raise Failure("API did not recover") + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--base-url", default="http://localhost:8080") + parser.add_argument("--short-ttl-only", action="store_true", + help="Use on a disposable stand with SESSION_TTL_SECONDS=2") + parser.add_argument("--dependency-stops", action="store_true") + args = parser.parse_args() + client = Client(args.base_url) + actor = client.user("atomic") + if args.short_ttl_only: + client.call("GET", "/api/v1/users/me", actor=actor, schema="User") + time.sleep(2.3) + client.call("GET", "/api/v1/users/me", 401, actor=actor) + print("PASS: active session expires without being refreshed by GET") + return + + registration = {"username": "race_" + uuid4().hex[:12], "display_name": "Race", + "password": secrets.token_urlsafe(24)} + + def register(_): + return Client(args.base_url).call("POST", "/api/v1/users", (201, 409), + body=registration)["status"] + + with ThreadPoolExecutor(2) as pool: + statuses = sorted(pool.map(register, range(2))) + check(statuses == [201, 409], f"expected one successful registration: {statuses}") + + list_path = "/api/v1/chats" + snapshot = client.call("GET", list_path, actor=actor, schema="ChatPage")["json"] + rejected = {"title": "must roll back", "member_ids": [actor["id"], str(uuid4())]} + client.call("POST", list_path, 400, actor=actor, body=rejected) + check(snapshot == client.call("GET", list_path, actor=actor, schema="ChatPage")["json"], + "a partial chat survived") + print("PASS: concurrent registration and atomic rollback of chat membership") + + if args.dependency_stops: + for service in ("cache", "db"): + try: + compose("stop", service) + client.call("GET", "/health/live", schema="Health") + client.call("GET", "/health/ready", 503) + client.call("GET", "/api/v1/users/me", 503, actor=actor) + print(f"PASS: {service} loss returns 503 without anonymous access") + finally: + compose("start", service) + await_ready(client) + client.call("GET", "/api/v1/users/me", actor=actor, schema="User") + client.call("DELETE", "/api/v1/auth/sessions/current", 204, actor=actor) + client.call("GET", "/api/v1/users/me", 401, actor=actor) + print("PASS: logout revokes the session") + + +if __name__ == "__main__": + main()