February 26, 2005 at 1:16 am
Two disjoint questions:
1) Does SQL server 2000 internally assign a unique record number to each row of a table regardless of the table has a PK or not? Probably, this value is used for indexing purpose?
2) In a very, very, simple system, the ONLY table has 3 columns:
UserId, Name, Good.
Data type of good is bit. We expect to query on Good.
Does it make any sense to index Good column to improve the performance?
Or we would be better off to store records in two seperate tables according to the value of Good.
February 26, 2005 at 6:10 am
SQl Server 200 does not have a unique record number like Oracle (I guess 
But U can wirte quiries to get the unique record number like in this article
http://www.sqlservercentral.com/columnists/dasanka/findminmaxvaluesinaset.asp
My Blog:
February 26, 2005 at 7:56 am
In your second question you asked about an index on a bit field helping. Actually, you can't index a bit field. SQL Server doesn't really need help with it, basically, and I would not suggest a separate table as you would be adding union requirements to get a list of all records.
If the phone doesn't ring...It's me.
February 28, 2005 at 1:59 am
Charles,
you *can* create indexes on BIT columns. At least with Query analyzer.
create table showme
(
c1 bit
)
create unique clustered index ci_prettyuseless on showme(c1)
select
objectproperty(object_id('showme'), 'TableHasClustIndex')
drop table showme
-----------
1
(1 row(s) affected)
,...but one might question the sense behind this, because selectivity isn't that high on such a column.
However, I think it might make sense to add a BIT column sometimes to get a covered index. But to judge on this, one needs to know what kind of queries will be run against this table.
As for the first question: No, SQL Server does not have such a number. However, internally SQL Server has a thing called RID, consisting of the file number : page number : slot number. Although you can't query it, you might want to read BOL about it.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
February 28, 2005 at 4:52 am
Frank,
Your answers sound logical. But I need a little more clearification. Please see my original questions at the begining of this thread. I will appretiate your time.
1. I do not intend to query by sql server internal RID. I just wanted to know if sql server maintains a RID for internal use. How else can SQL server core engine can map the indexing? Is it not that in addition to indexing the pages sql server also index rows? [Note - analogy: A printed book index only the page numbers not the line number - it can't because it doesn't have any line number.]
2. As I mentioned in the second part of my question that the ONLY query will be coming in with WHERE clause is on the bit column. I suspect, I will be better off by keeping two seperate tables instead of one with bit column indexed.
Thanks.
February 28, 2005 at 5:10 am
ad 1: SQL Server surely has internally a mechanism to access a row by its physical location. You have to distinguish between two possible cases. A table with only nonclustered indexex (a heap) on it. And a table with a clustered index on it. Basically both index structures are the same. Down to the leaf level. That's where they differ. A nonclustered index stores there among other, the RID, while a clustered index does store there the table data itself. This is a complex topic which is also explained in BOL. You might need to search a little bit, but under "indexes, architecture" you find some useful information about it. Also, see if these links help:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;311826
http://support.microsoft.com/default.aspx?scid=kb;EN-US;814324
http://support.microsoft.com/default.aspx?scid=kb;EN-US;325024
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/itwforsql.asp
ad 2) Might be better, since because of the low selectivity of such an index, SQL Server might not find that index useful anyway.
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
February 28, 2005 at 6:32 am
Frank,
I think you answered my questions. thanks a lot.
And yes, I was talking about non-cluster index.
February 28, 2005 at 7:16 am
You should make up a new thread for these new questions. Most people will scan the subject and therefore might miss this one. I for myself don't know anything about these things
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply