|
Posted by Robert Klemme on 11/28/17 11:58
cbrichards via SQLMonster.com wrote:
> So perhaps a little more information will be helpful.
>
> First of all, this is the query statement that generates the differing actual
> versus estimated rows:
>
> (The variables are of type int, sent as arguments to the stored procedure.)
>
> SELECT y.rpFID, x.dCode, x.Desc, x.dcUID
> FROM dbo.Table_X x
> JOIN dbo.Table_Y y
> ON x.dcUID = y.dcFID
> AND x.MainID = y.MainID
> JOIN dbo.Table_Z z
> ON y.rpFID = z.rpUID
> AND y.MainID = z.MainID
> WHERE z.pFID = @pID
> AND z.MainID = @MainID
> AND x.MainID = @MainID
> AND y.MainID = @MainID
Something likely unrelated to your issue (Erland answered that one
already) as it does not change the semantics of your statement but I
though I mention it nevertheless: it seems two of the last lines of this
SQL statement are pretty superfluous as all three tables are joined on
MainID anyway. So I'd leave only "AND x.MainID = @MainID" in there
because Table_X seems to be your major table.
Ah, and another remark: I find these table and column names highly
unspecific. Changing them to something more meaningful (identifiers are
not restricted to 8 characters) will probably help maintain the
application.
Kind regards
robert
Navigation:
[Reply to this message]
|