Se rendre au contenu
Odoo Menu
  • Se connecter
  • Essai gratuit
  • Applications
    Finance
    • Comptabilité
    • Facturation
    • Notes de frais
    • Feuilles de calcul (BI)
    • Documents
    • Signature
    Ventes
    • CRM
    • Ventes
    • PdV Boutique
    • PdV Restaurant
    • Abonnements
    • Location
    Sites web
    • Site Web
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Chaîne d'approvisionnement
    • Inventaire
    • Fabrication
    • PLM
    • Achats
    • Maintenance
    • Qualité
    Ressources Humaines
    • Employés
    • Recrutement
    • Congés
    • Évaluations
    • Recommandations
    • Parc automobile
    Marketing
    • Marketing Social
    • E-mail Marketing
    • SMS Marketing
    • Événements
    • Marketing Automation
    • Sondages
    Services
    • Projet
    • Feuilles de temps
    • Services sur Site
    • Assistance
    • Planification
    • Rendez-vous
    Productivité
    • Discussion
    • Intelligence artificielle
    • Internet des Objets
    • VoIP
    • Connaissances
    • WhatsApp
    Applications tierces Odoo Studio Plateforme Cloud d'Odoo
  • Industries
    Commerce de détail
    • Librairie
    • Magasin de vêtements
    • Magasin de meubles
    • Supermarché
    • Quincaillerie
    • Magasin de jouets
    Restauration & Hôtellerie
    • Bar et Pub
    • Restaurant
    • Fast-food
    • Maison d’hôtes
    • Distributeur de boissons
    • Hôtel
    Immobilier
    • Agence immobilière
    • Cabinet d'architecture
    • Construction
    • Gestion immobilière
    • Jardinage
    • Association de copropriétaires
    Consultance
    • Cabinet d'expertise comptable
    • Partenaire Odoo
    • Agence Marketing
    • Cabinet d'avocats
    • Aquisition de talents
    • Audit & Certification
    Fabrication
    • Textile
    • Métal
    • Meubles
    • Alimentation
    • Brasserie
    • Cadeaux d'entreprise
    Santé & Fitness
    • Club de sports
    • Opticien
    • Salle de fitness
    • Praticiens bien-être
    • Pharmacie
    • Salon de coiffure
    Commerce
    • Homme à tout faire
    • Matériel informatique & support
    • Systèmes photovoltaïques
    • Cordonnier
    • Services de nettoyage
    • Services CVC
    Autres
    • Organisation à but non lucratif
    • Agence environnementale
    • Location de panneaux d'affichage
    • Photographie
    • Leasing de vélos
    • Revendeur de logiciel
    Parcourir toutes les industries
  • Communauté
    Apprenez
    • Tutoriels
    • Documentation
    • Certifications
    • Formation
    • Blog
    • Podcast
    Renforcer l'éducation
    • Programme éducatif
    • Business Game Scale-Up!
    • Rendez-nous visite
    Obtenir le logiciel
    • Téléchargement
    • Comparez les éditions
    • Versions
    Collaborer
    • Github
    • Forum
    • Événements
    • Traductions
    • Devenir partenaire
    • Services pour partenaires
    • Enregistrer votre cabinet comptable
    Nos Services
    • Trouver un partenaire
    • Trouver un comptable
    • Rencontrer un conseiller
    • Services de mise en œuvre
    • Références clients
    • Assistance
    • Mises à niveau
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Obtenir une démonstration
  • Tarification
  • Aide
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Vous devez être inscrit pour interagir avec la communauté.
Toutes les publications Personnes Badges
Étiquettes (Voir toutl)
odoo accounting v14 pos v15
À propos de ce forum
Aide

Odoo Performance Discussion: Slow Deletes on Large Relational Models

S'inscrire

Recevez une notification lorsqu'il y a de l'activité sur ce poste

Cette question a été signalée
performancepostgresqlpostgresodoo
4 Réponses
1295 Vues
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Hi Odoo Community,

We are currently exploring ways to improve database performance in Odoo, and we would like to better understand real-world challenges faced by users.

One area we are particularly interested in is slow deletion performance in models with many relational fields and foreign key dependencies.

  • Have you encountered slow record deletions  in Odoo, especially in models with multiple relationships (Many2one, One2many, etc.)?
  • Does deleting large volumes of data (such as during cleanup, archiving, or module uninstallation) take a noticeable amount of time?
  • Have you observed delays caused by cascade deletions or foreign key constraint checks?
  • If yes, how are you currently handling these situations? (e.g., batching, custom scripts, raw SQL, or other workarounds)

We are trying to understand:

  • How frequently this issue occurs in real-world Odoo deployments
  • At what data scale it starts becoming a bottleneck

Your feedback and real-world experiences would be extremely valuable in helping us identify practical requirements for improving Odoo performance.

Regards

0
Avatar
Ignorer
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Auteur Meilleure réponse

Hi,


We’ve found a solution for this issue while working on PostgreSQL-level optimizations specifically for Odoo workloads, and we observed that foreign key validation was a major bottleneck during large delete operations.

In Odoo, many core models contain deep relational dependencies (`Many2one`, `One2many`, cascading deletes, computed relations, etc.). When deleting large datasets or uninstalling modules, PostgreSQL must repeatedly validate foreign key constraints and trigger cascade checks across multiple related tables.


From our benchmark testing across multiple PostgreSQL versions (15, 16, 17, and 18), we noticed that:


* Foreign key trigger validation time increases significantly with large relational datasets

* Missing or inefficient indexes on foreign key columns heavily impact deletion speed

* Cascade delete operations become slower as dependency depth and row count increase

* Module uninstallation in Odoo can become extremely slow when tables contain millions of related records


Based on these observations, we believe there are two important optimization areas:


1. Improving Foreign Key Validation Performance in PostgreSQL


We are currently exploring PostgreSQL source-level optimizations to reduce the overhead of FK trigger validation during delete and update operations.


Since Odoo relies heavily on relational integrity, optimizing FK checks could significantly improve:


* Bulk deletions

* Module uninstallations

* Cleanup operations

* Archiving workflows

* Large transactional updates


Our internal testing indicates that FK validation overhead becomes much more visible at multi-million row scale deployments.


2. Automatic Index Suggestion for Foreign Key Columns


Another major issue we observed is that many slow deletions are caused by missing indexes on foreign key columns.


Although PostgreSQL automatically indexes primary keys, foreign key columns themselves are not automatically indexed. In Odoo deployments with large relational datasets, this can cause expensive sequential scans during FK validation.


We are exploring an automatic index suggestion mechanism that could:


* Detect heavily-used FK columns

* Suggest or create optimized indexes for relational operations

* Improve delete/update validation speed

* Reduce cascade operation cost

* Improve overall ORM performance in Odoo


In many cases, proper FK indexing alone noticeably reduced deletion time during our tests.


We believe combining:


* FK validation optimization

* Better relational indexing strategies

* Odoo-specific workload tuning


could significantly improve PostgreSQL performance for large-scale Odoo environments.


It would be very interesting to know:


* At what table size users start seeing deletion slowdowns

* Which Odoo modules are most affected

* Whether the issue occurs mainly during module uninstallations, scheduled cleanups, or normal business operations


Regards

0
Avatar
Ignorer
Avatar
Ali Khalid
Meilleure réponse

Yes, I've faced this exact issue. Slow deletions become a bottleneck past 50K records with heavy relational fields. Cascade deletes and FK constraint checks easily take 30+ seconds for just 10K records.

I see it regularly during:

  • Module uninstalls (ir.model.data cascades)

  • CRM campaign cleanups

  • Stock move archiving

My current approach:

  • Batch unlink: records[0:1000].unlink() via cron job (~80% faster)

  • Raw SQL: DELETE FROM model WHERE id IN (...) + VACUUM ANALYZE

  • Archive first: Set active=False, then purge later

This keeps things manageable up to 1M records with proper indexing.

0
Avatar
Ignorer
Avatar
Vraja Technologies
Meilleure réponse

Yes In So many Cases Like Delete Product (In Link With Sale Order,Invoice,Inventory,Picking etc) 

uninstalling a custom module after it has been used for months or years. it'getting long time to uninstall because of lot's of relation and business data.

Right now We are handling this way.

The First Way is Archive the Records
For ex Products
It's link to stock,sales,purchase,invoice

so it's hard to delete
faster than deep delete chains
=================================
Another Option is
Delete child/dependent records first

Do not always rely only on cascade deletion.

Better approach:

identify dependent models
remove deeper child records first
then delete parent records

=================================
Raw SQL can be faster, but should be used only when:

cleanup of temporary import tables
large log/history cleanup
Avoid For Stock and Accounting entries

I hope this will help for you. please give feedback/suggestion.

Thanks


0
Avatar
Ignorer
Avatar
Perz, ODOO_Aspirant
Meilleure réponse

In general " DELETION " of data is not a recommended solution

Other alternatives :

CHeck the indexes  - implement  wherever you need

In case if you use any third party security apps

If it is .sh environment - you can consider  to " move the attachment to a shared location"  - So ODOO will have url o nly -when user click only document will load

-1
Avatar
Ignorer
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !

Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !

S'inscrire
Publications associées Réponses Vues Activité
Odoo Performance Analysis: Bottlenecks in Deleting Large Relational Records
performance wizard postgresql postgres odoo
Avatar
0
avr. 26
7
Odoo Performance Issue
performance postgresql odoo
Avatar
0
janv. 17
6253
No passwd entry for user 'postgres' in odoo 12
postgresql postgres odoo odoo12
Avatar
1
déc. 19
11653
Have You Faced Slow Pagination in Odoo List Views with Large Data?
postgresql odoo
Avatar
0
avr. 26
868
Seeking Odoo Server Performance configuration/ advice / tips / benchmarks for 60 concurrent users
performance postgresql workers tuning odoo
Avatar
0
mars 24
6432
Communauté
  • Tutoriels
  • Documentation
  • Forum
Open Source
  • Téléchargement
  • Github
  • Runbot
  • Traductions
Services
  • Hébergement Odoo.sh
  • Assistance
  • Migration
  • Développements personnalisés
  • Éducation
  • Trouver un comptable
  • Trouver un partenaire
  • Devenir partenaire
À propos
  • Notre société
  • Actifs de la marque
  • Contactez-nous
  • Emplois
  • Événements
  • Podcast
  • Blog
  • Clients
  • Informations légales • Confidentialité
  • Sécurité.
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk Slovenščina Español (América Latina) Español Svenska ภาษาไทย Türkçe українська Tiếng Việt

Odoo est une suite d'applications open source couvrant tous les besoins de votre entreprise : CRM, eCommerce, Comptabilité, Inventaire, Point de Vente, Gestion de Projet, etc.

Le positionnement unique d'Odoo est d'être à la fois très facile à utiliser et totalement intégré.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now