简体   繁体   中英

What option do I have to insert data into a denormalized table

A denormalized table (sort of summary table) been created in the database, hoping that it will improve performance.

  • This table will be clean up daily using batch job (HardDelete)
  • No constraint is needed for this table (As it may compromise performance)
  • Speed will be the main concern

Background is that originally, there is a search action thru a large size of a table(says tableA) as there are always new insertion so the table grown into large size. Now whenever there is new insertion into the tableA, we will insert into this newTable and the searching will be against this newTable instead and since this newTable will have batchjob hard delete on daily basis, the size will be much controllable.

Now I'm wondering what are the options I have in order to insert data into this newTable. My current option is either putting a trigger on tableA or the normal way (going thru server code to insert data into this newTable after insertion to TableA). Is there any other option which can help in boosting the speed?

A trigger will be faster than adding it to your server side code, as the data has already reached the database. Your main concern will be transactions (what happens if the trigger fails?) and also maintenance of triggers (triggers are a pain to maintain if you ask me).

For raw insert speed you can check your table locking settings, disable read safety and disable all constraints.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM