Quantcast
Channel: SQLServerCentral » SQL Server 2012 » SQL Server 2012 - T-SQL » Latest topics
Viewing all articles
Browse latest Browse all 4901

Disadvantage if using View to Insert Data?

$
0
0
Hi there,For my DWH I am using partitioning for all my bigger tables.As I would like to use two dimensions for partitioning I decided to create different tables to splitt the years.To query the data I use a view that simply joins the data:CREATE VIEW view_all_yearsWITH SCHEMABINDINGSELECT datum, attribute1_id, attribute2_idFROM table_2012UNION ALLSELECT datum, attribute1_id, attribute2_idFROM table_2013The following contrains help the optimizer to eliminate tables that are not needed for the queries.ALTER TABLE table_2012 WITH CHECK ADD CONSTRAINT [CK_table_2012] CHECK (([date]>='2012-01-01' AND [date]<='2012-12-31'))ALTER TABLE table_2013 WITH CHECK ADD CONSTRAINT [CK_table_2013] CHECK (([date]>='2013-01-01' AND [date]<='2013-12-31'))However I am now thinking, if I could use the same view to insert the data, so I do not have to check, if the data I am importing belongs to which table an so do not have to react with the INSERT statement in my ETL.I tried to insert data and it works: insert into view_all_years(datum, attribute1_id, attribute2_id)VALUES('2012-01-01', 1, 2),('2013-01-01', 1, 2)While it is technical possible, I would like to now, if I have disadvantages in performance with this?I saw in the execution plan, that it plans to insert the data in all underlying tables while a insert into into the specified table wouldn't.To specify my enviroment:SQL Server 2012 SP1 EEI will have to insert more then 20 mio rows a dayI am looking forward to your thoughtMitch

Viewing all articles
Browse latest Browse all 4901

Trending Articles