Skip to content

Conversation

maxcorbeau
Copy link
Contributor

@maxcorbeau maxcorbeau commented Apr 21, 2025

⏩ DBT: modèles unlogged / désactiver le WAL

Carte Notion: ⏩ DBT: modèles unlogged / désactiver le WAL

🗺️ contexte: on utilise dbt pour compiler de la donnée, par défault le WAL de postresql est activé alors qu'on en a pas besoin pour des modèles recompilés / reconstruit de zero à chaque fois

💡 quoi: rendre les modèles unlogged

🎯 pourquoi: désactiver le WAL et améliorer les performances, cf https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-UNLOGGED

If specified, the table is created as an unlogged table. Data written to unlogged tables is ⏩ not written to the write-ahead log (see Chapter 28), which makes them 🚀 considerably faster than ordinary tables. However, they are ⚠️ not crash-safe: an unlogged table is automatically truncated after a crash or unclean shutdown. The contents of an unlogged table are also not replicated to standby servers. Any indexes created on an unlogged table are automatically unlogged as well. If this is specified, any sequences created together with the unlogged table (for identity or serial columns) are also created as unlogged.

=> 🟢 dans le pire des cas quelque chose ne se passe pas bien et dbt doit reconstuire le modèle dans son intégralité, ce qui est déjà le cas actuellement = pas de regression

🤔 comment: option dans dbt_project.yml

✅ Reste à faire (PR en cours)

  • Comparer les performances avant / après activation de l'option sur un full build

📆 A faire (prochaine PR)

  • Si un jour on implémente les modèles incremental: alors désactiver le unlogged pour ses modèles car on ne veut pas être victime d'un TRUNCATE et perdre l'ensemble de l'historique
  • Django: mettre la table de cache Django également en unlogged

@maxcorbeau maxcorbeau added enhancement New feature or request dbt labels Apr 21, 2025
@maxcorbeau maxcorbeau requested a review from a team as a code owner April 21, 2025 10:58
@maxcorbeau maxcorbeau requested review from kolok and fabienheureux and removed request for a team April 21, 2025 10:58
@maxcorbeau maxcorbeau changed the title ⏩ DBT: modèles unlogged / désactiver le WAL ⏩ [PERF] DBT: modèles unlogged / désactiver le WAL Apr 21, 2025
Copy link

@kolok kolok force-pushed the dbt_unlogged_v1 branch from 2bbf5ef to 1b4037b Compare April 24, 2025 07:34
@kolok kolok enabled auto-merge (squash) April 24, 2025 07:34
@kolok kolok merged commit 028a24a into main Apr 24, 2025
8 checks passed
@kolok kolok deleted the dbt_unlogged_v1 branch April 24, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dbt enhancement New feature or request performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants