table scan

  • Hiya'll When I run this query the execution plan shows a table scan: (uid is primary key identity col 1,2,3,..)

    SELECT MAX(uid) AS Expr1

    FROM dbo.wmsLog

    It also shows a table scan if I do:

    Select top 1 from

    FROM dbo.wmsLog

    order by uid desc

    The table has about 1.6 million rows and the first query takes 59secs and the second is only slightly faster at 47secs.

    I would have thought with primary key it would have been allot faster as it simply has to seek the last index entry.

    Can anyone shed some light on this?

    Thanks

     

     

     

     

     

    Dave

    Trainmark.com IT Training B2B Marketplace
    (Jobs for IT Instructors)

  • My bad, guess it was a late night and when I rebuilt the table I didn't add the primary key back in...duh!

    is much faster now

     

    Dave

    Trainmark.com IT Training B2B Marketplace
    (Jobs for IT Instructors)

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply