Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Artificial Intelligence
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Property Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Odoo Performance Discussion: Slow Deletes on Large Relational Models

Subscribe

Get notified when there's activity on this post

This question has been flagged
performancepostgresqlpostgresodoo
4 Replies
1291 Views
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
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Author Best Answer

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
Discard
Avatar
Ali Khalid
Best Answer

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
Discard
Avatar
Vraja Technologies
Best Answer

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
Discard
Avatar
Perz, ODOO_Aspirant
Best Answer

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
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Odoo Performance Analysis: Bottlenecks in Deleting Large Relational Records
performance wizard postgresql postgres odoo
Avatar
0
Apr 26
7
Odoo Performance Issue
performance postgresql odoo
Avatar
0
Jan 17
6244
No passwd entry for user 'postgres' in odoo 12
postgresql postgres odoo odoo12
Avatar
1
Dec 19
11639
Have You Faced Slow Pagination in Odoo List Views with Large Data?
postgresql odoo
Avatar
0
Apr 26
858
Seeking Odoo Server Performance configuration/ advice / tips / benchmarks for 60 concurrent users
performance postgresql workers tuning odoo
Avatar
0
Mar 24
6425
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة 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 is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

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