citusdata / pg_shard

ATTENTION: pg_shard is superseded by Citus, its more powerful replacement
https://github.com/citusdata/citus
GNU Lesser General Public License v3.0
1.06k stars 63 forks source link

Propagate triggers affecting distributed tables #74

Open coryfoo opened 9 years ago

coryfoo commented 9 years ago

It would be nice if triggers associated with a table were automatically propagated across all databases when the table sharding occurs. Perhaps it could be an optional flag, as I could envision scenarios where this might be undesirable.

jasonmp85 commented 9 years ago

Quoting your mailing list post:

We have some triggers that run on INSERT, DELETE, and UPDATE (for a specific column value) of one of our biggest tables (the primary target for sharding). It is critical that these triggers still function when writing into the distributed tables. One caveat, however, is that it would be a burden for the trigger to fire multiple times in the case of a replicated shard. We are using these triggers as a way to track necessary updates to another datastore based on specific conditions.

In your particular case, which would be most desirable:

This is a pretty big feature space, so details will help us evaluate feasibility in the future.

Additionally: You said your triggers run after a successful modification. What do they do? Are they writing to some other table? Enqueuing a job? If they do write to another table, would you need that table to be distributed as well?