Giter Site home page Giter Site logo

Foreign Key on replicated tables about tbase HOT 6 OPEN

yazun avatar yazun commented on June 9, 2024
Foreign Key on replicated tables

from tbase.

Comments (6)

JennyJennyChen avatar JennyJennyChen commented on June 9, 2024

Other colleagues may add this code just to want to limit the data writing of the replicated table to only consider this node, and not care about other nodes to enhance the performance of data writing.

from tbase.

yazun avatar yazun commented on June 9, 2024

Could this be enabled with the config/compile switch?

from tbase.

JennyJennyChen avatar JennyJennyChen commented on June 9, 2024

Regarding the reason for prohibiting the foreign key on the replication table, I consulted the relevant personnel. The main reason is that there can be no triggers on the replication table, and the foreign keys in the PG are also implemented by triggers, so the foreign keys are also prohibited.
If you are sure that you are not using triggers on the replicated table, you can remove this if statement in the source code and recompile the new bin to solve:
image

from tbase.

yazun avatar yazun commented on June 9, 2024

So the question emerges why we could not have triggers on the replicated table, granted such triggers would not use anything distributed?
It seems it would be consistent with other limitations coming from distribution, maybe a GUC allowing for this would make sense?

from tbase.

JennyJennyChen avatar JennyJennyChen commented on June 9, 2024

The replication table is that all DN nodes have full data about this table, and all DN nodes will perform operations on this data. Then suppose that there is a trigger on this replicated table: when inserting data, add the inserted data to another non-replicated table, then this non-replicated table will have N pieces of data (N is the number of DN nodes).

Triggers can be used in distributed systems, but replication tables cannot be used, shard tables can be used.

from tbase.

yazun avatar yazun commented on June 9, 2024

Sure, there's limitation that a trigger cannot touch sharded tables. The same caveat comes already i.e. with functions that could be executed on DNs only if used in the from part of the query - if they have DML inside such function would be possibly only executed on a single DN, corrupting the schema.
I think it is fine if the risk is well understood and a GUC allowing for it would be most welcome.

from tbase.

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.