View 'instead of' update row with new object

From: Tom Dearman <tom(dot)dearman(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: View 'instead of' update row with new object
Date: 2015-01-08 12:02:41
Message-ID: EE2FCBAC-38D6-4814-BEA4-CBFEE8AC79A8@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am partitioning a number of tables in our system and am using a view on the real master table with 'instead of’ triggers to insert and update rows. I have used a view because my application uses Hibernate which does not work well with triggers that return a null to indicate no further processing (Hibernate will interpret this as 0 inserts/updates). This all works well but when using the ‘instead of’ trigger, when a column value is changed, I must write a big clause with multiple 'set columnName = NEW.columnName’. I am also generating the scripts for all tables with a generic generator and since the tables have different columns this part of the script must be table specific. Is there any way to do something like update tableName * = New. Or would there be a cost to deleting the row then inserting again - I have read that postgres does this anyway, but I assume it may do this in some efficient way which may not require index updates etc.

Browse pgsql-general by date

  From Date Subject
Next Message deans 2015-01-08 12:15:40 Re: BDR Error restarted
Previous Message Maxim Boguk 2015-01-08 03:49:19 Re: Improving performance of merging data between tables