- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Relational databases query slowness in views and solution #ai #claude #indian #tech #singaporetech
Why is your PostgreSQL query suddenly 10x slower after recreating a view? Here’s the hidden reason no one talks about.
🔍 The Core Problem
• Recreating a view in PostgreSQL drops and replaces the underlying query plan
• The query planner loses all previously gathered statistics and cached execution plans
• pg_statistic data tied to the view context gets stale or reset
⚙️ Why the Planner Struggles
• PostgreSQL’s query optimizer relies on table statistics (via ANALYZE) to pick the best plan
• After recreation, the planner may choose a sequential scan over an index scan until stats are refreshed
• Views don’t cache results — every query re-executes the full underlying SQL
📉 What Makes It Worse
• Materialized views vs regular views behave differently — regular views offer zero caching
• JIT compilation warmup adds overhead on first few executions post-recreation
• Connection pools may hold stale plan caches from pg_prepared_statements
✅ What Developers Should Do Instead
• Run ANALYZE on underlying tables immediately after recreating a view
• Use CREATE OR REPLACE VIEW instead of DROP + CREATE where possible
• Consider materialized views + REFRESH MATERIALIZED VIEW for read-heavy workloads
• Monitor with EXPLAIN (ANALYZE, BUFFERS) before and after
Видео Relational databases query slowness in views and solution #ai #claude #indian #tech #singaporetech канала ByteSizeDiaries
🔍 The Core Problem
• Recreating a view in PostgreSQL drops and replaces the underlying query plan
• The query planner loses all previously gathered statistics and cached execution plans
• pg_statistic data tied to the view context gets stale or reset
⚙️ Why the Planner Struggles
• PostgreSQL’s query optimizer relies on table statistics (via ANALYZE) to pick the best plan
• After recreation, the planner may choose a sequential scan over an index scan until stats are refreshed
• Views don’t cache results — every query re-executes the full underlying SQL
📉 What Makes It Worse
• Materialized views vs regular views behave differently — regular views offer zero caching
• JIT compilation warmup adds overhead on first few executions post-recreation
• Connection pools may hold stale plan caches from pg_prepared_statements
✅ What Developers Should Do Instead
• Run ANALYZE on underlying tables immediately after recreating a view
• Use CREATE OR REPLACE VIEW instead of DROP + CREATE where possible
• Consider materialized views + REFRESH MATERIALIZED VIEW for read-heavy workloads
• Monitor with EXPLAIN (ANALYZE, BUFFERS) before and after
Видео Relational databases query slowness in views and solution #ai #claude #indian #tech #singaporetech канала ByteSizeDiaries
Комментарии отсутствуют
Информация о видео
23 мая 2026 г. 12:05:39
00:00:45
Другие видео канала
