Re: max(keyfield)
From: jxstern (jxstern_at_nowhere.com)
Date: 11/15/04
- Next message: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Previous message: Jack: "Re: Error Message: Transaction cannot start while in firehose mode"
- In reply to: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Next in thread: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Reply: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 15 Nov 2004 14:38:25 -0800
On Mon, 15 Nov 2004 15:18:06 -0500, "Aaron [SQL Server MVP]"
<ten.xoc@dnartreb.noraa> wrote:
>> So a seek is better than a scan, anyway, and it can do this even for a
>> clustered index because the top index page has a last row. I just
>> wondered if it might do even better and cache the high value,
>
>No, I don't think individual column values can be cached the way you are
>describing.
Just the high and low.
>However, for your education, wouldn't it be relatively simple to set up a
>simple test?
Well, yeah, I guess, but sometimes it feels more productive to ask
than to do the reverse engineering, and some happy lurker might
benefit thereby.
>CREATE TABLE Kerplunk
>(
> foo INT,
> bar INT,
> raboof INT
>)
>GO
>
>CREATE CLUSTERED INDEX f ON Kerplunk(foo)
>CREATE INDEX f ON Kerplunk(foo)
on (bar), I suppose you meant.
>GO
>
>SET NOCOUNT ON
>-- <<< populate data here! >>>
>-- hit Ctrl+K to see execution plan
>-- it will show where scans/seeks are used...
>
>SELECT * FROM Kerplunk WHERE foo = (SELECT MAX(foo) FROM Kerplunk)
>
>SELECT * FROM Kerplunk WHERE bar = (SELECT MAX(bar) FROM Kerplunk)
>
>SELECT * FROM Kerplunk WHERE raboof = (SELECT MAX(raboof) FROM Kerplunk)
>GO
>
>DROP TABLE Kerplunk
>GO
- Next message: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Previous message: Jack: "Re: Error Message: Transaction cannot start while in firehose mode"
- In reply to: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Next in thread: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Reply: Aaron [SQL Server MVP]: "Re: max(keyfield)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|