Re: can't force index
From: Britney (britneychen_2001_at_yahoo.com)
Date: 02/18/05
- Next message: Sgt. Sausage: "Re: Hardest Query of My Life.. :) (Help Please!)"
- Previous message: NB: "Re: Status Column in sysobjects table...SQL2000"
- In reply to: Gert-Jan Strik: "Re: can't force index"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 18 Feb 2005 18:49:57 -0500
Oh my god, sorry guys.
I was wrong about it, "users" is not a table, but it's a view.
I just found out.
In case you ask me why i'm doing this stupid view:
the reason we create a view for this is because I want to do snapshot
isolation for read and write.
if there are data coming in to [2users] table, then I alter view to use
[1users] table. So users table have 2 tables:
Read and write. This way I don't worry about locking.
-------------------------
CREATE VIEW users
AS
select * from [2users]
---------------------------
Now We know what is happening....
IF I select from actual table ,
select user_name from [2users] (index=user_name_index)
where user_name='Joe'
I see that it 's using forced index.
I guess view doesn't work correctly for some reason.
--------------------------------------------------------------
sp_spaceused [2users]
result:
name rows reserved data index_size unused
[2users] 41892 13952 KB 6616 KB 7144 KB 192 KB
-----------------------------------------------------------------
select @@version
result:
Microsoft SQL Server 2000 - 8.00.780 (Intel X86) Mar 3 2003 10:28:28
Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows
NT 5.0 (Build 2195: Service Pack 4)
-----------------------------------------------------------------------
> 1) How big is the table? How many pages (blocks of 8 Kilobyte) does the
> table use? You can check this with "sp_spaceused".
>
"Gert-Jan Strik" <sorry@toomuchspamalready.nl> wrote in message
news:42166EA6.EA6900C3@toomuchspamalready.nl...
> 1) How big is the table? How many pages (blocks of 8 Kilobyte) does the
> table use? You can check this with "sp_spaceused".
>
> 2) What version of SQL-Server are you using
>
> 3) Please post (simplified) DDL and some sample rows, and preferably a
> script to reproduce the behavior.
>
> Gert-Jan
>
>
> Britney wrote:
> >
> > user_name_index is used on "user_name" column,
> >
> > but even when I execute
> >
> > select user_name from users (index=user_name_index)
> > where user_name='Joe'
> >
> > I still see the execution plan is using clustered index "user_id_index".
> >
> > don't you think it's weird?
- Next message: Sgt. Sausage: "Re: Hardest Query of My Life.. :) (Help Please!)"
- Previous message: NB: "Re: Status Column in sysobjects table...SQL2000"
- In reply to: Gert-Jan Strik: "Re: can't force index"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|