Solved

How to reduce update time?

Posted on 2011-03-01
4
268 Views
Last Modified: 2012-05-11
Hi there,

I have two major tables:
Product Stock Levels = 2.3m rows
Product = 4.2m rows

It takes about 2hr 15 mins to run this Stored Procedure below and complete. I need some assistance to how I can improve this update to be shortened? I understand that JOINS can be written as OUTER AND INNER JOIN OR LEFT JOIN. Can anyone help to clarify?

Thank you.

UPDATE Product SET
StockLevel = 1,
DisabledFlag = 0,
PriceAmt = CAST(igmsi.PublisherPrice AS MONEY)/100,
DiscountPercent=CASE WHEN PriceAmt>14.90 THEN 20 ELSE 15 END
From Stock_update.dbo.Product_Stock_Update igmsi
JOIN Product ON igmsi.ISBN=Product.ISBN
Where Product.Producttype='Books'
0
Comment
Question by:cq27
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 35014244
first you need to make sure that you have proper indexes on these columns
Product ON igmsi.ISBN, Product.ISBN , Product.Producttype
0
 

Author Comment

by:cq27
ID: 35014401
Hi there,

Will indexing be useful if the Product Stock file keeps changing? I receive a new product file in ASCII txt format daily and I generally will truncate the Product Stock table before inserting the new full data.

I also need some help on how indexing works. Thank you.
0
 
LVL 11

Accepted Solution

by:
JoeNuvo earned 125 total points
ID: 35014450
regardless of Product Stock keep changing.
in order to make your update query run fast
this should be expecting to have

1. Clustered index of field ISBN on table Product and Product_Stock_Update
2. Index of field ProductType on table Product

if number of rows going to update is just partial of table Product.
above index should help
0
 

Author Closing Comment

by:cq27
ID: 35014544
Thanks for the advice and direction. I will have to work out the indexing and try it for myself.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question