Coder Social home page Coder Social logo

Comments (2)

maxtepkeev avatar maxtepkeev commented on June 7, 2024

Great question.

When a new record is inserted into a table, partitioned by architect, it is actually inserted into child and parent table at the same time, but immediately deleted by parentTableName_delete_master() trigger function, that is where this bloat on parent table comes from.

Now you are probably wondering why this happens, because in an ideal world a record should be really inserted only into the child table. This happens because parentTableName_insert_child() trigger function generated by architect finishes with RETURN NEW; instead of RETURN NULL; statement which makes PostgreSQL to insert a new record into parent table as well.

Now the final question is why architect is doing that. Well, because otherwise ORMs (at least the Django ORM) just don't work, because they expect a record to be returned after an insert statement has been issued to the database. This is a legacy code from django-db-parti package and there is a record in my TODO list to check if it's still an issue for other ORMs and the latest Django versions but I just currently don't have much time to do that ;(

I hope I answered your question, if not feel free to ask more. By the way there is a tool called pg_repack it is a successor to a pg_reorg tool and it's now in active development so it's worth trying.

from architect.

ramusus avatar ramusus commented on June 7, 2024

Yes, thanks a lot

from architect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.