Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

How to speed up update table against views

Hi experts,

I have a table, table_1, which contained half million records. I am updating it with more than 10 views once at a time. And it takes me forever. I didn't create any index for those views. I do created a cluster index and copule index for the table. One of the updating scripts like the following:

/****/
UPDATE table_1
SET table.product = 'Book'
FROM  table_1 ,vw_2005  
WHERE (table_1.ACCOUNT_ID = vw_2005.ACCOUNT_ID)
       AND (table_1.[YEAR] = 2005)
       AND (table_1.product IS NULL)
 

My question is
A. how can I speed up the update process?

B. Should I add those options to those views?
"SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL,ARITHABORT,QUOTED_IDENTIFIER,ANSI_NULLS ON
GO"

C.  should I add the statment "WITH   SCHEMABINDING " to the create view line?  
Thanks,  
0
LIULIHUA
Asked:
LIULIHUA
  • 3
  • 3
1 Solution
 
hardikbeitCommented:
U can also add
SET NOCOUNT ON in the beginning and SET NOCOUNT OFF at last
0
 
LIULIHUAAuthor Commented:
Hi hardikbeit,

Do you mean add
"SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING,ANSI_WARNINGS,CONCAT_NULL_YIELDS_NULL,ARITHABORT,QUOTED_IDENTIFIER,ANSI_NULLS ON
GO"
and also add "SET NOCOUNT ON in the beginning and SET NOCOUNT OFF at last" ?

0
 
hardikbeitCommented:
Hi LIULIHUA,
that's right.

As per my knowledge without this command the SQL Query Analyzer gives total no of records updated. There is no need to see howmany rows updated each times, it decrease performance due to switching between sql query processor and IO.
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LIULIHUAAuthor Commented:
Hi hardikbeit ,

if I don't want to set up index for the view then the only thing I need to set up is "SET NOCOUNT ON in the beginning and SET NOCOUNT OFF at last", am i right? because set up an indexed view are sort of complecated, what do you think?

0
 
hardikbeitCommented:
Hi Liulihua,
Yes you are right.

Index View is really a good option to improve your performance.

If you want to know how to create and use, check this link:
http://www.sqlteam.com/item.asp?ItemID=1015

you can improve performance with View Indexes, if applications that do any of the following may benefit as well:
-Joins and aggregations of big tables
-Repeated patterns of queries
-Repeated aggregations on the same or overlapping sets of columns
-Repeated joins of the same tables on the same keys
0
 
LIULIHUAAuthor Commented:
Thank you hardikbeit, this is very benefit for my project.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now