Nubbin question :(

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • WangKhar

    Nubbin question :(

    create table guidtest(a int primary key clustered, b uniqueidentifie r,
    c varchar(200))

    insert into guidtest values (1, newid(), 'ashakhfoagfoah fafdsa')
    insert into guidtest values (45, newid(), 'EWRYEYYTURJ')
    insert into guidtest values (231, newid(), 'WYEW')
    insert into guidtest values (73573, newid(),
    'ashakhgs\YEW5Y foagfoahfafdsa' )
    insert into guidtest values (463784, newid(),
    'ashakhfoagDGHH DDfoahfafdsa')
    insert into guidtest values (416571371, newid(),
    'ashakXHSDFSGRS Rhfoagfoahfafds a')


    select * from guidtest where b =
    '9EE19242-5C78-4520-9F0A-365A42237BB0'

    select * from guidtest where c = 'ashakhfoagDGHH DDfoahfafdsa'

    Query plans for the 2 queries show pk scan.

    My sarg isn't on the pk. Am I just being a nub?
  • lucjanc

    #2
    Re: Nubbin question :(

    Hello, primary key scan, is another way of saying clustered index scan, or
    simply clustered table scan. Since you have clustered index there, table
    scan = clustered index scan. Saying all that , whether optimazer will pick
    index or scan also depends also on size of the table. In your case table is
    small , fits on one page, 2 pages when has index. So scan of the table I/O
    costs is 1 page, when using index 2 pages. Better to scan in this particular
    case :)). But, in general it all depends on cost analysis that are done by
    optimazer.

    cheers,

    Lucjan



    "WangKhar" <Wangkhar@yahoo .com> wrote in message
    news:bb269444.0 401160411.584d4 00b@posting.goo gle.com...[color=blue]
    > create table guidtest(a int primary key clustered, b uniqueidentifie r,
    > c varchar(200))
    >
    > insert into guidtest values (1, newid(), 'ashakhfoagfoah fafdsa')
    > insert into guidtest values (45, newid(), 'EWRYEYYTURJ')
    > insert into guidtest values (231, newid(), 'WYEW')
    > insert into guidtest values (73573, newid(),
    > 'ashakhgs\YEW5Y foagfoahfafdsa' )
    > insert into guidtest values (463784, newid(),
    > 'ashakhfoagDGHH DDfoahfafdsa')
    > insert into guidtest values (416571371, newid(),
    > 'ashakXHSDFSGRS Rhfoagfoahfafds a')
    >
    >
    > select * from guidtest where b =
    > '9EE19242-5C78-4520-9F0A-365A42237BB0'
    >
    > select * from guidtest where c = 'ashakhfoagDGHH DDfoahfafdsa'
    >
    > Query plans for the 2 queries show pk scan.
    >
    > My sarg isn't on the pk. Am I just being a nub?[/color]


    Comment

    Working...