Thread: Is this best performed using a trigger?
I'm trying to decide if this task is best performed using triggers or some other method in the application itself. Basically I have two tables. When I insert (or update) data in one table I want to compare the inserted or updated data with the already existing data in the other table and see if there are any matches. If there are I want to flag up that match somehow (I haven't decided on how to do that just yet but lets just say it'll send an email or something for the purposes of this question). So given the fact that I need to ensure the best possible performance whilst also acknowledging that there could be a significant amount of data in the tables would a trigger function be the best method to use? Assuming a trigger function is the best method to use would it be beneficial to write it in C or would there only be a negligible performance increase by doing so and that using PL/pgSQL would be better simply for ease of use and deployment?