Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1113256%22%20slang%3D%22en-US%22%3ELesson%20Learned%20%23120%3A%20What%20is%20the%20impact%20of%20having%20an%20Indexed%20View%20during%20a%20data%20import%20process%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1113256%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20we%20have%20been%20working%20on%20an%20important%20issue%20that%20our%20customer%20reported%20that%20during%20a%20data%26nbsp%3B%20import%20process%2C%20in%20this%20case%2C%20using%20a%20bacpac%2C%20took%20too%20much%20time.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDuring%20the%20importing%20process%20we%20were%20checking%20the%20performance%20of%20the%20client%20machine%20and%20database%2C%20in%20fact%2C%20we%20scaled%20up%20to%20one%20of%20the%20most%20powerfull%20database%20tiers%20in%20Azure%20SQL%20Database.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ERunning%20the%20command%3A%20SELECT%20*%20FROM%20sys.dm_db_resouce_stats%20%3CSTRONG%3Ewe%20saw%20that%20CPU%2C%20IO%20or%20LOG%20consumption%20are%20not%20high.%3C%2FSTRONG%3E%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EReviewing%20Resource%20Monitor%20of%20the%20client%20machine%20%3CSTRONG%3Ewhere%20SQLPackage%20is%20running%20the%20CPU%2C%20IO%20and%20Network%20usage%20are%20not%20high%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EIn%20this%20situation%2C%20as%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Ftools%2Fsqlpackage%3Fview%3Dsql-server-ver15%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3ESQLPackage%3C%2FA%3E%20is%20using%2C%20by%20default%2C%208%20threads%20to%20import%20the%20data%2C%20we%20tried%20to%20find%20out%20if%20there%20is%20any%20blocking%20issue%20that%20may%20cause%20this%20problem.%3CUL%3E%0A%3CLI%3EWe%20executed%20the%20query%20that%20we%20have%20in%20this%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-database-support-blog%2Flesson-learned-22-how-to-identify-blocking-issues%2Fba-p%2F368865%22%20target%3D%22_self%22%3EURL%3C%2FA%3E%26nbsp%3Band%20we%20found%20that%20%3CSTRONG%3E7%20sessions%20are%20waiting%20for%20a%20session%20and%20all%20of%20them%3C%2FSTRONG%3E%20are%20running%20Bulk%20Insert%20command.%26nbsp%3B%3CUL%3E%0A%3CLI%3EWe%20reviewed%20several%20details%20of%20the%20tables%20%3CSTRONG%3Eand%20we%20found%20that%20the%20blocking%20issues%3C%2FSTRONG%3E%20are%20coming%20from%20tables%20that%20have%20multiple%20views.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EWe%20found%20that%20these%20views%20are%20indexed%20views%20%3CSTRONG%3Ethat%20are%20causing%20these%20blockings%20because%20we%20have%208%20sessions%20that%20are%20adding%20data%20and%20depending%20on%20the%20definition%20of%20the%20view%20(some%20of%20them%20have%20count%2Csum%20operators)%20are%20impacting%20in%20the%20process%20because%20needs%20to%20be%20evaluated%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3ERunning%20this%20TSQL%20we%20found%20the%20indexed%20views%20(contains%20an%20index)%20and%20we%20removed%20them%20%3A%26nbsp%3BSELECT%20o.name%20as%20view_name%2C%20i.name%20as%20index_name%3CBR%20%2F%3EFROM%20sysobjects%20o%20%3CBR%20%2F%3EINNER%20JOIN%20sysindexes%20i%20%3CBR%20%2F%3EON%20o.id%20%3D%20i.id%20%3CBR%20%2F%3EWHERE%20o.xtype%20%3D%20'V'%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EAfter%20removing%20all%20of%20them%2C%20%3CSTRONG%3Ethe%20importing%20process%20was%20reduce%20several%20hours%3C%2FSTRONG%3E%20and%20after%20it%20we%20were%20able%20to%20r%3CSTRONG%3Ee-create%20the%20indexed%20views%3C%2FSTRONG%3E.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnjoy!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1113256%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20we%20have%20been%20working%20on%20an%20important%20issue%20that%20our%20customer%20reported%20that%20during%20a%20data%26nbsp%3B%20import%20process%2C%20in%20this%20case%2C%20using%20a%20bacpac%2C%20took%20too%20much%20time.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E

Today, we have been working on an important issue that our customer reported that during a data  import process, in this case, using a bacpac, took too much time. 

 

During the importing process we were checking the performance of the client machine and database, in fact, we scaled up to one of the most powerfull database tiers in Azure SQL Database. 

 

  • Running the command: SELECT * FROM sys.dm_db_resouce_stats we saw that CPU, IO or LOG consumption are not high. 
  • Reviewing Resource Monitor of the client machine where SQLPackage is running the CPU, IO and Network usage are not high
  • In this situation, as SQLPackage is using, by default, 8 threads to import the data, we tried to find out if there is any blocking issue that may cause this problem.
    • We executed the query that we have in this URL and we found that 7 sessions are waiting for a session and all of them are running Bulk Insert command. 
      • We reviewed several details of the tables and we found that the blocking issues are coming from tables that have multiple views. 
      • We found that these views are indexed views that are causing these blockings because we have 8 sessions that are adding data and depending on the definition of the view (some of them have count,sum operators) are impacting in the process because needs to be evaluated
    • Running this TSQL we found the indexed views (contains an index) and we removed them : SELECT o.name as view_name, i.name as index_name
      FROM sysobjects o
      INNER JOIN sysindexes i
      ON o.id = i.id
      WHERE o.xtype = 'V' 
    • After removing all of them, the importing process was reduce several hours and after it we were able to re-create the indexed views

 

Enjoy!