Solved

How to reduce update time?

Posted on 2011-03-01
4
266 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
section a string 5 52
CAST issue with SQL 2000 15 42
How to use Recordset, returned from a SPROC as the recourdsource of a form. 24 47
TDE for SQL Web Edition 1 29
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

738 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