Re: Optimizer not using the good index
From: Peter Yeoh (nospam_at_nospam.com)
Date: 10/14/04
- Next message: Jonathan Yong: "Re: SQL2000: Could not locate file name ... in sysfiles"
- Previous message: Paul: "SQL2000: Could not locate file name ... in sysfiles"
- In reply to: Don: "Optimizer not using the good index"
- Next in thread: Anthony E. Castro: "Re: Optimizer not using the good index"
- Reply: Anthony E. Castro: "Re: Optimizer not using the good index"
- Reply: Mark Wilden: "Re: Optimizer not using the good index"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 14 Oct 2004 11:16:43 +0800
As David Browne asked, how many rows are there in WO with Cmd_No=814352?
Assuming that you are 100% sure that using the nonclustered index is better,
I would guess that the statistics are inaccurate.
To test this, use Query Analyzer and look at the estimated execution plan
for the query. Open another window and get the actual execution plan.
Compare the estimated number of rows against the actual number of rows
retrieved for each process. Somewhere in there, there should be a wide
divergence, which should indicate inaccurate statistics. Run the UPDATE
STATISTICS command for the relevant index with the FULLSCAN option. Might
not work always since SQL Server only maintains distribution stats for 200
steps and you have millions of rows in the table, but worth a shot.
-- Peter Yeoh http://www.yohz.com Need smaller SQL2K backup files? Use MiniSQLBackup Lite, free! "Don" <anonymous@discussions.microsoft.com> wrote in message news:2c8801c4b170$5415b9e0$a501280a@phx.gbl... > Please, > > Using SQL 7.0 > > The optimizer is not using the good index for this query > > It's using the clustered index X2 (on WOT_DATE instead of > index X1 on WO_REF. > > I did reindex but it's still the same. It looks to > happen every monday after i run sp_updatestats > > What should i do or i should not do > > SELECT 0 > FROM WOTransit (readuncommitted) > INNER JOIN WO (readuncommitted) On > WoTransit.Wo_ref=Wo.Wo_ref > WHERE WO.Cmd_No=814352 > AND ISNULL(WOTransit.Charge_ref,0) <> 0 > > thanks > > Don
- Next message: Jonathan Yong: "Re: SQL2000: Could not locate file name ... in sysfiles"
- Previous message: Paul: "SQL2000: Could not locate file name ... in sysfiles"
- In reply to: Don: "Optimizer not using the good index"
- Next in thread: Anthony E. Castro: "Re: Optimizer not using the good index"
- Reply: Anthony E. Castro: "Re: Optimizer not using the good index"
- Reply: Mark Wilden: "Re: Optimizer not using the good index"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|