If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
054 rows. I notice that the values returned in the IndexName column are not
all index names, but also include statistic names [_WA_Sys_...] and regular
column names. This is the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
If I take the same database used above, and restore it to SQL 2005, then run
the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
notice that the values returned in the IndexName column are all valid index
names, and DO NOT include statistic names and regular column names. This is
the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
In order to get the two to retrieve the same results, or stated another way,
in order to get the SQL 2000 version to return just index names (and not also
statistic names [_WA_Sys_...] and regular column names), what do I need to do?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200610/1
Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
sysindexes.status & 0x20=0 to identify real indexes."
http://msdn2.microsoft.com/en-us/library/ms190172.aspx
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 14:46:56 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>054 rows. I notice that the values returned in the IndexName column are not
>all index names, but also include statistic names [_WA_Sys_...] and regular
>column names. This is the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
> WHERE s.object_id > 99
>If I take the same database used above, and restore it to SQL 2005, then run
>the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
>notice that the values returned in the IndexName column are all valid index
>names, and DO NOT include statistic names and regular column names. This is
>the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
>WHERE s.object_id > 99
>
>In order to get the two to retrieve the same results, or stated another way,
>in order to get the SQL 2000 version to return just index names (and not also
>statistic names [_WA_Sys_...] and regular column names), what do I need to do?
|||Thanks Ron, that did the trick.
However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
to be performing a bitwise logical AND operation. So what I am trying to make
sense, if I have a unique clustered index with a status of 18, then if I plug
that into a converter (18 & 0x20), it does not = 0, but 24. Can you
enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
0x20) = 0"? Thanks.
Roy Harvey wrote:[vbcol=seagreen]
>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>sysindexes.status & 0x20=0 to identify real indexes."
>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>Roy Harvey
>Beacon Falls, CT
>[quoted text clipped - 26 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200610/1
|||You simply add that to the WHERE clause:
SELECT O.name AS TableName,
I.name AS IndexName
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 16:32:18 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
[vbcol=seagreen]
>Thanks Ron, that did the trick.
>However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
>to be performing a bitwise logical AND operation. So what I am trying to make
>sense, if I have a unique clustered index with a status of 18, then if I plug
>that into a converter (18 & 0x20), it does not = 0, but 24. Can you
>enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
>0x20) = 0"? Thanks.
>Roy Harvey wrote:
|||What I am trying to say is this...
Let's say I run the following:
SELECT TOP 1 i.status
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
I return the value: 18
My binary representation for 18 = 0011000100111000
My binary representation for 0x20 = 00110000011110000011001000110000
BOL says: "The & bitwise operator performs a bitwise logical AND between the
two expressions, taking each corresponding bit for both expressions. The bits
in the result are set to 1 if and only if both bits (for the current bit
being resolved) in the input expressions have a value of 1; otherwise, the
bit in the result is set to 0."
If I compare the binary representations, then I do not see how (in the query
statement above) "I.status & 0x20 = 0" or written with the returned value "18
& 0x20 = 0", when both bits = 1 on several instances.
I am not disputing the SQL statement works (returning only real indexes), as
it certainly does. What I am trying to understand is how the "Logical AND"
statement = 0.
Roy Harvey wrote:[vbcol=seagreen]
>You simply add that to the WHERE clause:
>SELECT O.name AS TableName,
> I.name AS IndexName
> FROM sysobjects O
> JOIN sysindexes I
> ON O.id = I.id
> WHERE I.id > 99
> AND I.status & 0x20 = 0
>Roy Harvey
>Beacon Falls, CT
>[quoted text clipped - 18 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forums...erver/200610/1
|||On Mon, 23 Oct 2006 17:24:10 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
>My binary representation for 18 = 0011000100111000
0011000100111000 represents the ASCII CHARACTER STRING '18'. Binary
for the NUMBER 18 = 10010.
>My binary representation for 0x20 = 00110000011110000011001000110000
0x20 is hexidecimal 20, or decimal 32, or binary 100000; a single bit
is "on".
Roy Harvey
Beacon Falls, CT
Showing posts with label following. Show all posts
Showing posts with label following. Show all posts
Friday, March 30, 2012
Index statement on SQL 2000 vs. SQL 2005
If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
054 rows. I notice that the values returned in the IndexName column are not
all index names, but also include statistic names [_WA_Sys_...] and regu
lar
column names. This is the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
If I take the same database used above, and restore it to SQL 2005, then run
the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
notice that the values returned in the IndexName column are all valid index
names, and DO NOT include statistic names and regular column names. This is
the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
In order to get the two to retrieve the same results, or stated another way,
in order to get the SQL 2000 version to return just index names (and not als
o
statistic names [_WA_Sys_...] and regular column names), what do I need
to do?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
sysindexes.status & 0x20=0 to identify real indexes."
http://msdn2.microsoft.com/en-us/library/ms190172.aspx
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 14:46:56 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
[vbcol=seagreen]
>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2
,
>054 rows. I notice that the values returned in the IndexName column are not
>all index names, but also include statistic names [_WA_Sys_...] and reg
ular
>column names. This is the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
> WHERE s.object_id > 99
>If I take the same database used above, and restore it to SQL 2005, then ru
n
>the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows.
I
>notice that the values returned in the IndexName column are all valid inde
x
>names, and DO NOT include statistic names and regular column names. This is
>the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
>WHERE s.object_id > 99
>
>In order to get the two to retrieve the same results, or stated another way
,
>in order to get the SQL 2000 version to return just index names (and not al
so
>statistic names [_WA_Sys_...] and regular column names), what do I need to do?[
/vbcol]|||Thanks Ron, that did the trick.
However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appear
s
to be performing a bitwise logical AND operation. So what I am trying to mak
e
sense, if I have a unique clustered index with a status of 18, then if I plu
g
that into a converter (18 & 0x20), it does not = 0, but 24. Can you
enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
0x20) = 0"? Thanks.
Roy Harvey wrote:[vbcol=seagreen]
>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>sysindexes.status & 0x20=0 to identify real indexes."
>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>Roy Harvey
>Beacon Falls, CT
>
>[quoted text clipped - 26 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1|||You simply add that to the WHERE clause:
SELECT O.name AS TableName,
I.name AS IndexName
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 16:32:18 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
[vbcol=seagreen]
>Thanks Ron, that did the trick.
>However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appea
rs
>to be performing a bitwise logical AND operation. So what I am trying to ma
ke
>sense, if I have a unique clustered index with a status of 18, then if I pl
ug
>that into a converter (18 & 0x20), it does not = 0, but 24. Can you
>enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
>0x20) = 0"? Thanks.
>Roy Harvey wrote:|||What I am trying to say is this...
Let's say I run the following:
SELECT TOP 1 i.status
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
I return the value: 18
My binary representation for 18 = 0011000100111000
My binary representation for 0x20 = 00110000011110000011001000110000
BOL says: "The & bitwise operator performs a bitwise logical AND between the
two expressions, taking each corresponding bit for both expressions. The bit
s
in the result are set to 1 if and only if both bits (for the current bit
being resolved) in the input expressions have a value of 1; otherwise, the
bit in the result is set to 0."
If I compare the binary representations, then I do not see how (in the query
statement above) "I.status & 0x20 = 0" or written with the returned value "1
8
& 0x20 = 0", when both bits = 1 on several instances.
I am not disputing the SQL statement works (returning only real indexes), as
it certainly does. What I am trying to understand is how the "Logical AND"
statement = 0.
Roy Harvey wrote:[vbcol=seagreen]
>You simply add that to the WHERE clause:
>SELECT O.name AS TableName,
> I.name AS IndexName
> FROM sysobjects O
> JOIN sysindexes I
> ON O.id = I.id
> WHERE I.id > 99
> AND I.status & 0x20 = 0
>Roy Harvey
>Beacon Falls, CT
>
>[quoted text clipped - 18 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1|||On Mon, 23 Oct 2006 17:24:10 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
>My binary representation for 18 = 0011000100111000
0011000100111000 represents the ASCII CHARACTER STRING '18'. Binary
for the NUMBER 18 = 10010.
>My binary representation for 0x20 = 00110000011110000011001000110000
0x20 is hexidecimal 20, or decimal 32, or binary 100000; a single bit
is "on".
Roy Harvey
Beacon Falls, CT
054 rows. I notice that the values returned in the IndexName column are not
all index names, but also include statistic names [_WA_Sys_...] and regu
lar
column names. This is the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
If I take the same database used above, and restore it to SQL 2005, then run
the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
notice that the values returned in the IndexName column are all valid index
names, and DO NOT include statistic names and regular column names. This is
the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
In order to get the two to retrieve the same results, or stated another way,
in order to get the SQL 2000 version to return just index names (and not als
o
statistic names [_WA_Sys_...] and regular column names), what do I need
to do?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
sysindexes.status & 0x20=0 to identify real indexes."
http://msdn2.microsoft.com/en-us/library/ms190172.aspx
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 14:46:56 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
[vbcol=seagreen]
>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2
,
>054 rows. I notice that the values returned in the IndexName column are not
>all index names, but also include statistic names [_WA_Sys_...] and reg
ular
>column names. This is the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
> WHERE s.object_id > 99
>If I take the same database used above, and restore it to SQL 2005, then ru
n
>the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows.
I
>notice that the values returned in the IndexName column are all valid inde
x
>names, and DO NOT include statistic names and regular column names. This is
>the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
>WHERE s.object_id > 99
>
>In order to get the two to retrieve the same results, or stated another way
,
>in order to get the SQL 2000 version to return just index names (and not al
so
>statistic names [_WA_Sys_...] and regular column names), what do I need to do?[
/vbcol]|||Thanks Ron, that did the trick.
However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appear
s
to be performing a bitwise logical AND operation. So what I am trying to mak
e
sense, if I have a unique clustered index with a status of 18, then if I plu
g
that into a converter (18 & 0x20), it does not = 0, but 24. Can you
enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
0x20) = 0"? Thanks.
Roy Harvey wrote:[vbcol=seagreen]
>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>sysindexes.status & 0x20=0 to identify real indexes."
>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>Roy Harvey
>Beacon Falls, CT
>
>[quoted text clipped - 26 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1|||You simply add that to the WHERE clause:
SELECT O.name AS TableName,
I.name AS IndexName
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 16:32:18 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
[vbcol=seagreen]
>Thanks Ron, that did the trick.
>However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appea
rs
>to be performing a bitwise logical AND operation. So what I am trying to ma
ke
>sense, if I have a unique clustered index with a status of 18, then if I pl
ug
>that into a converter (18 & 0x20), it does not = 0, but 24. Can you
>enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
>0x20) = 0"? Thanks.
>Roy Harvey wrote:|||What I am trying to say is this...
Let's say I run the following:
SELECT TOP 1 i.status
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
I return the value: 18
My binary representation for 18 = 0011000100111000
My binary representation for 0x20 = 00110000011110000011001000110000
BOL says: "The & bitwise operator performs a bitwise logical AND between the
two expressions, taking each corresponding bit for both expressions. The bit
s
in the result are set to 1 if and only if both bits (for the current bit
being resolved) in the input expressions have a value of 1; otherwise, the
bit in the result is set to 0."
If I compare the binary representations, then I do not see how (in the query
statement above) "I.status & 0x20 = 0" or written with the returned value "1
8
& 0x20 = 0", when both bits = 1 on several instances.
I am not disputing the SQL statement works (returning only real indexes), as
it certainly does. What I am trying to understand is how the "Logical AND"
statement = 0.
Roy Harvey wrote:[vbcol=seagreen]
>You simply add that to the WHERE clause:
>SELECT O.name AS TableName,
> I.name AS IndexName
> FROM sysobjects O
> JOIN sysindexes I
> ON O.id = I.id
> WHERE I.id > 99
> AND I.status & 0x20 = 0
>Roy Harvey
>Beacon Falls, CT
>
>[quoted text clipped - 18 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200610/1|||On Mon, 23 Oct 2006 17:24:10 GMT, "cbrichards via droptable.com"
<u3288@.uwe> wrote:
>My binary representation for 18 = 0011000100111000
0011000100111000 represents the ASCII CHARACTER STRING '18'. Binary
for the NUMBER 18 = 10010.
>My binary representation for 0x20 = 00110000011110000011001000110000
0x20 is hexidecimal 20, or decimal 32, or binary 100000; a single bit
is "on".
Roy Harvey
Beacon Falls, CT
Index statement on SQL 2000 vs. SQL 2005
If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
054 rows. I notice that the values returned in the IndexName column are not
all index names, but also include statistic names [_WA_Sys_...] and regular
column names. This is the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
If I take the same database used above, and restore it to SQL 2005, then run
the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
notice that the values returned in the IndexName column are all valid index
names, and DO NOT include statistic names and regular column names. This is
the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
In order to get the two to retrieve the same results, or stated another way,
in order to get the SQL 2000 version to return just index names (and not also
statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
sysindexes.status & 0x20=0 to identify real indexes."
http://msdn2.microsoft.com/en-us/library/ms190172.aspx
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 14:46:56 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>054 rows. I notice that the values returned in the IndexName column are not
>all index names, but also include statistic names [_WA_Sys_...] and regular
>column names. This is the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
> WHERE s.object_id > 99
>If I take the same database used above, and restore it to SQL 2005, then run
>the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
>notice that the values returned in the IndexName column are all valid index
>names, and DO NOT include statistic names and regular column names. This is
>the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
>WHERE s.object_id > 99
>
>In order to get the two to retrieve the same results, or stated another way,
>in order to get the SQL 2000 version to return just index names (and not also
>statistic names [_WA_Sys_...] and regular column names), what do I need to do?|||Thanks Ron, that did the trick.
However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
to be performing a bitwise logical AND operation. So what I am trying to make
sense, if I have a unique clustered index with a status of 18, then if I plug
that into a converter (18 & 0x20), it does not = 0, but 24. Can you
enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
0x20) = 0"? Thanks.
Roy Harvey wrote:
>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>sysindexes.status & 0x20=0 to identify real indexes."
>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>Roy Harvey
>Beacon Falls, CT
>>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>>054 rows. I notice that the values returned in the IndexName column are not
>[quoted text clipped - 26 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1|||You simply add that to the WHERE clause:
SELECT O.name AS TableName,
I.name AS IndexName
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 16:32:18 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>Thanks Ron, that did the trick.
>However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
>to be performing a bitwise logical AND operation. So what I am trying to make
>sense, if I have a unique clustered index with a status of 18, then if I plug
>that into a converter (18 & 0x20), it does not = 0, but 24. Can you
>enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
>0x20) = 0"? Thanks.
>Roy Harvey wrote:
>>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>>sysindexes.status & 0x20=0 to identify real indexes."
>>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>>Roy Harvey
>>Beacon Falls, CT
>>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>>054 rows. I notice that the values returned in the IndexName column are not
>>[quoted text clipped - 26 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?|||What I am trying to say is this...
Let's say I run the following:
SELECT TOP 1 i.status
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
I return the value: 18
My binary representation for 18 = 0011000100111000
My binary representation for 0x20 = 00110000011110000011001000110000
BOL says: "The & bitwise operator performs a bitwise logical AND between the
two expressions, taking each corresponding bit for both expressions. The bits
in the result are set to 1 if and only if both bits (for the current bit
being resolved) in the input expressions have a value of 1; otherwise, the
bit in the result is set to 0."
If I compare the binary representations, then I do not see how (in the query
statement above) "I.status & 0x20 = 0" or written with the returned value "18
& 0x20 = 0", when both bits = 1 on several instances.
I am not disputing the SQL statement works (returning only real indexes), as
it certainly does. What I am trying to understand is how the "Logical AND"
statement = 0.
Roy Harvey wrote:
>You simply add that to the WHERE clause:
>SELECT O.name AS TableName,
> I.name AS IndexName
> FROM sysobjects O
> JOIN sysindexes I
> ON O.id = I.id
> WHERE I.id > 99
> AND I.status & 0x20 = 0
>Roy Harvey
>Beacon Falls, CT
>>Thanks Ron, that did the trick.
>[quoted text clipped - 18 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1|||On Mon, 23 Oct 2006 17:24:10 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>My binary representation for 18 = 0011000100111000
0011000100111000 represents the ASCII CHARACTER STRING '18'. Binary
for the NUMBER 18 = 10010.
>My binary representation for 0x20 = 00110000011110000011001000110000
0x20 is hexidecimal 20, or decimal 32, or binary 100000; a single bit
is "on".
Roy Harvey
Beacon Falls, CT
054 rows. I notice that the values returned in the IndexName column are not
all index names, but also include statistic names [_WA_Sys_...] and regular
column names. This is the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
If I take the same database used above, and restore it to SQL 2005, then run
the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
notice that the values returned in the IndexName column are all valid index
names, and DO NOT include statistic names and regular column names. This is
the statement:
SELECT
s.name AS TableName,
i.name AS IndexName
FROM sys.objects s
JOIN sys.indexes i
ON s.object_id = i.object_id
WHERE s.object_id > 99
In order to get the two to retrieve the same results, or stated another way,
in order to get the SQL 2000 version to return just index names (and not also
statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
sysindexes.status & 0x20=0 to identify real indexes."
http://msdn2.microsoft.com/en-us/library/ms190172.aspx
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 14:46:56 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>054 rows. I notice that the values returned in the IndexName column are not
>all index names, but also include statistic names [_WA_Sys_...] and regular
>column names. This is the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
> WHERE s.object_id > 99
>If I take the same database used above, and restore it to SQL 2005, then run
>the following statement on SQL 2005 Standard Edition, SP1, I get 647 rows. I
>notice that the values returned in the IndexName column are all valid index
>names, and DO NOT include statistic names and regular column names. This is
>the statement:
>SELECT
> s.name AS TableName,
> i.name AS IndexName
>FROM sys.objects s
>JOIN sys.indexes i
> ON s.object_id = i.object_id
>WHERE s.object_id > 99
>
>In order to get the two to retrieve the same results, or stated another way,
>in order to get the SQL 2000 version to return just index names (and not also
>statistic names [_WA_Sys_...] and regular column names), what do I need to do?|||Thanks Ron, that did the trick.
However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
to be performing a bitwise logical AND operation. So what I am trying to make
sense, if I have a unique clustered index with a status of 18, then if I plug
that into a converter (18 & 0x20), it does not = 0, but 24. Can you
enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
0x20) = 0"? Thanks.
Roy Harvey wrote:
>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>sysindexes.status & 0x20=0 to identify real indexes."
>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>Roy Harvey
>Beacon Falls, CT
>>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>>054 rows. I notice that the values returned in the IndexName column are not
>[quoted text clipped - 26 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1|||You simply add that to the WHERE clause:
SELECT O.name AS TableName,
I.name AS IndexName
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
Roy Harvey
Beacon Falls, CT
On Mon, 23 Oct 2006 16:32:18 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>Thanks Ron, that did the trick.
>However, how do I make sense of "(sysindexes.status & 0x20) = 0"? It appears
>to be performing a bitwise logical AND operation. So what I am trying to make
>sense, if I have a unique clustered index with a status of 18, then if I plug
>that into a converter (18 & 0x20), it does not = 0, but 24. Can you
>enlighten me how (18 & 0x20), for example = 0, or how "(sysindexes.status &
>0x20) = 0"? Thanks.
>Roy Harvey wrote:
>>Found this on MSDN: "For Microsoft SQL Server 2000, use the predicate
>>sysindexes.status & 0x20=0 to identify real indexes."
>>http://msdn2.microsoft.com/en-us/library/ms190172.aspx
>>Roy Harvey
>>Beacon Falls, CT
>>If I run the following statement on SQL 2000 Standard Edition, SP4, I get 2,
>>054 rows. I notice that the values returned in the IndexName column are not
>>[quoted text clipped - 26 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?|||What I am trying to say is this...
Let's say I run the following:
SELECT TOP 1 i.status
FROM sysobjects O
JOIN sysindexes I
ON O.id = I.id
WHERE I.id > 99
AND I.status & 0x20 = 0
I return the value: 18
My binary representation for 18 = 0011000100111000
My binary representation for 0x20 = 00110000011110000011001000110000
BOL says: "The & bitwise operator performs a bitwise logical AND between the
two expressions, taking each corresponding bit for both expressions. The bits
in the result are set to 1 if and only if both bits (for the current bit
being resolved) in the input expressions have a value of 1; otherwise, the
bit in the result is set to 0."
If I compare the binary representations, then I do not see how (in the query
statement above) "I.status & 0x20 = 0" or written with the returned value "18
& 0x20 = 0", when both bits = 1 on several instances.
I am not disputing the SQL statement works (returning only real indexes), as
it certainly does. What I am trying to understand is how the "Logical AND"
statement = 0.
Roy Harvey wrote:
>You simply add that to the WHERE clause:
>SELECT O.name AS TableName,
> I.name AS IndexName
> FROM sysobjects O
> JOIN sysindexes I
> ON O.id = I.id
> WHERE I.id > 99
> AND I.status & 0x20 = 0
>Roy Harvey
>Beacon Falls, CT
>>Thanks Ron, that did the trick.
>[quoted text clipped - 18 lines]
>>in order to get the SQL 2000 version to return just index names (and not also
>>statistic names [_WA_Sys_...] and regular column names), what do I need to do?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200610/1|||On Mon, 23 Oct 2006 17:24:10 GMT, "cbrichards via SQLMonster.com"
<u3288@.uwe> wrote:
>My binary representation for 18 = 0011000100111000
0011000100111000 represents the ASCII CHARACTER STRING '18'. Binary
for the NUMBER 18 = 10010.
>My binary representation for 0x20 = 00110000011110000011001000110000
0x20 is hexidecimal 20, or decimal 32, or binary 100000; a single bit
is "on".
Roy Harvey
Beacon Falls, CT
Wednesday, March 28, 2012
Index Scanning
Please read following statements. statement 1 runs very faster and uses index scan. The statement 2 runs very slow uses table scan.
The Following things are already done.
DBCC DBREINDEX
Sp_updatestats
update statistics
It is only affecting one column (date_added) and also other statistic name start with _WA_SYS_* but date column starts as statistic_date_added. This has happened only for the last two days. All the production store procedure accessing date_columns now running longer.
Is there anybod can explain this and please post a solution. ?
Raj Sankar
Statement 1.
select * from rx_control where store_id = @.store_id and date_added between '08/01/02' and '08/20/02'
------------------------
statement 2.
------------
declare @.bdate as datetime
declare @.edate as datetime
declare @.rxid as int
set @.store_id = '52'
set @.rxid = '158315'
set @.bdate = '08/01/02'
set @.edate = '08/10/02'
select * from rx_control where store_id = @.store_id and date_added between @.bdate and @.edate
------------------------check with dbcc showcontig report and depending on this u should go for dbcc indexfrag on respective fields.
if still the problem persists send me the showcontig report for the respectve table if u can.|||I had problem like this or very similar.
Query optimizer creates an execution plan based on conditions. For the first statement optimizer knows date range exactly and creates the best execution plan.
The second statement is using local variables and optimizer creates common execution plan (without using particular conditions).
How to resolve this problem? In my situation I created additional table where parameters were saved and I was using join. It looks like a stupid decision but it works.
You can try to use this idea.
Good luck
The Following things are already done.
DBCC DBREINDEX
Sp_updatestats
update statistics
It is only affecting one column (date_added) and also other statistic name start with _WA_SYS_* but date column starts as statistic_date_added. This has happened only for the last two days. All the production store procedure accessing date_columns now running longer.
Is there anybod can explain this and please post a solution. ?
Raj Sankar
Statement 1.
select * from rx_control where store_id = @.store_id and date_added between '08/01/02' and '08/20/02'
------------------------
statement 2.
------------
declare @.bdate as datetime
declare @.edate as datetime
declare @.rxid as int
set @.store_id = '52'
set @.rxid = '158315'
set @.bdate = '08/01/02'
set @.edate = '08/10/02'
select * from rx_control where store_id = @.store_id and date_added between @.bdate and @.edate
------------------------check with dbcc showcontig report and depending on this u should go for dbcc indexfrag on respective fields.
if still the problem persists send me the showcontig report for the respectve table if u can.|||I had problem like this or very similar.
Query optimizer creates an execution plan based on conditions. For the first statement optimizer knows date range exactly and creates the best execution plan.
The second statement is using local variables and optimizer creates common execution plan (without using particular conditions).
How to resolve this problem? In my situation I created additional table where parameters were saved and I was using join. It looks like a stupid decision but it works.
You can try to use this idea.
Good luck
Monday, March 26, 2012
Index Ratification
Hi all,
I'm going through the process of identifying which items in my tables to
place indexes on.
I'm using the following general rules in deciding usage. Can anyone advise
whether these are correct?
- All primary keys to be a clustered index.
- All foreign keys to be unclustered.
- Items which are heavily used in WHERE etc are also unclustered.
DJWA bit simplified. What is the datatype of your PK? Is it int (identity) or
something else? Is it sequential?
As far as th FK goes yeah, I would say yes. There are no really general
rules, it all depends but I would say that those steps are a good start. You
do need to think really hard on your indexing however, perhaps performanse
could be better with some changes.
MC
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:4396883f$1_1@.glkas0286.greenlnk.net...
> Hi all,
> I'm going through the process of identifying which items in my tables to
> place indexes on.
> I'm using the following general rules in deciding usage. Can anyone
> advise
> whether these are correct?
> - All primary keys to be a clustered index.
> - All foreign keys to be unclustered.
> - Items which are heavily used in WHERE etc are also unclustered.
> DJW
>|||Daniel,
I would generalize it like this:
For a VERY write intensive table:
Only clustered index on the PK being a column containing sequential values.
For a more read intensive table:
Nonclustered on the PK (since we will usually only fetch one row at a time
from it)
Nonclustered for searches that find few rows.
Clustered (or covered nonclustered) for searches that find many rows
(typically FK or Date columns).
The "most important" FK of the table is usually a good column to use for the
clustered index. Many searches on it, returns many rows, small data type :-)
/ Tobias|||Is this an OLTP (operational) database or a Data Warehouse used for
reporting purposes?
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:4396883f$1_1@.glkas0286.greenlnk.net...
> Hi all,
> I'm going through the process of identifying which items in my tables to
> place indexes on.
> I'm using the following general rules in deciding usage. Can anyone
> advise
> whether these are correct?
> - All primary keys to be a clustered index.
> - All foreign keys to be unclustered.
> - Items which are heavily used in WHERE etc are also unclustered.
> DJW
>|||It's an OLTP, JT
"JT" <someone@.microsoft.com> wrote in message
news:e8zGYbz#FHA.228@.TK2MSFTNGP12.phx.gbl...
> Is this an OLTP (operational) database or a Data Warehouse used for
> reporting purposes?
> "Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
> news:4396883f$1_1@.glkas0286.greenlnk.net...
>|||Then perhaps optimizing inserts/upadtes/deletes is more important than
optimizing queries. In that case, minimizing the number of indexes and
avoiding clustered indexes.
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:43970494$1_1@.glkas0286.greenlnk.net...
> It's an OLTP, JT
> "JT" <someone@.microsoft.com> wrote in message
> news:e8zGYbz#FHA.228@.TK2MSFTNGP12.phx.gbl...
>sql
I'm going through the process of identifying which items in my tables to
place indexes on.
I'm using the following general rules in deciding usage. Can anyone advise
whether these are correct?
- All primary keys to be a clustered index.
- All foreign keys to be unclustered.
- Items which are heavily used in WHERE etc are also unclustered.
DJWA bit simplified. What is the datatype of your PK? Is it int (identity) or
something else? Is it sequential?
As far as th FK goes yeah, I would say yes. There are no really general
rules, it all depends but I would say that those steps are a good start. You
do need to think really hard on your indexing however, perhaps performanse
could be better with some changes.
MC
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:4396883f$1_1@.glkas0286.greenlnk.net...
> Hi all,
> I'm going through the process of identifying which items in my tables to
> place indexes on.
> I'm using the following general rules in deciding usage. Can anyone
> advise
> whether these are correct?
> - All primary keys to be a clustered index.
> - All foreign keys to be unclustered.
> - Items which are heavily used in WHERE etc are also unclustered.
> DJW
>|||Daniel,
I would generalize it like this:
For a VERY write intensive table:
Only clustered index on the PK being a column containing sequential values.
For a more read intensive table:
Nonclustered on the PK (since we will usually only fetch one row at a time
from it)
Nonclustered for searches that find few rows.
Clustered (or covered nonclustered) for searches that find many rows
(typically FK or Date columns).
The "most important" FK of the table is usually a good column to use for the
clustered index. Many searches on it, returns many rows, small data type :-)
/ Tobias|||Is this an OLTP (operational) database or a Data Warehouse used for
reporting purposes?
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:4396883f$1_1@.glkas0286.greenlnk.net...
> Hi all,
> I'm going through the process of identifying which items in my tables to
> place indexes on.
> I'm using the following general rules in deciding usage. Can anyone
> advise
> whether these are correct?
> - All primary keys to be a clustered index.
> - All foreign keys to be unclustered.
> - Items which are heavily used in WHERE etc are also unclustered.
> DJW
>|||It's an OLTP, JT
"JT" <someone@.microsoft.com> wrote in message
news:e8zGYbz#FHA.228@.TK2MSFTNGP12.phx.gbl...
> Is this an OLTP (operational) database or a Data Warehouse used for
> reporting purposes?
> "Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
> news:4396883f$1_1@.glkas0286.greenlnk.net...
>|||Then perhaps optimizing inserts/upadtes/deletes is more important than
optimizing queries. In that case, minimizing the number of indexes and
avoiding clustered indexes.
"Daniel J Watkins" <danielwatkinslearn@.hotmail.com> wrote in message
news:43970494$1_1@.glkas0286.greenlnk.net...
> It's an OLTP, JT
> "JT" <someone@.microsoft.com> wrote in message
> news:e8zGYbz#FHA.228@.TK2MSFTNGP12.phx.gbl...
>sql
Index question
I have the following index:
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
GO
Thanks for any feedback........
DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Loginid] and
[logindate]). If you create the second index, may be SQL Server can decide to
use it because the key is shorter than the first one, so more rows can fit in
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........
|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........
|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>
>
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
GO
Thanks for any feedback........
DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Loginid] and
[logindate]). If you create the second index, may be SQL Server can decide to
use it because the key is shorter than the first one, so more rows can fit in
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........
|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........
|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>
>
Index Question
Hi,
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
Dee
The pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
>)
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee
|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in the
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
>
|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in the
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT
sql
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
Dee
The pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
>)
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee
|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in the
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
>
|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in the
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT
sql
Labels:
database,
following,
index,
int,
microsoft,
mysql,
null,
nvarchar,
oracle,
projectcode,
projectresource,
resourceid,
revisionnum,
server,
sql,
table,
tablecreate
Index question
Hello,
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
Thanks in advance,
sck10
Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>
|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/de...us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!
|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
Thanks in advance,
sck10
Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>
|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/de...us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!
|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>
Index question
I have the following index:
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Log
inid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) O
N [PRIMARY]
GO
Thanks for any feedback........DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Login
id] and
[logindate]). If you create the second index, may be SQL Server can deci
de to
use it because the key is shorter than the first one, so more rows can fit i
n
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([
Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]
) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([L
oginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid])
ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to se
ek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>
>
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Log
inid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) O
N [PRIMARY]
GO
Thanks for any feedback........DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Login
id] and
[logindate]). If you create the second index, may be SQL Server can deci
de to
use it because the key is shorter than the first one, so more rows can fit i
n
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([
Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]
) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([L
oginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid])
ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to se
ek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>
>
Labels:
91dbo,
91login_table,
91loginid,
91myindex1,
91primarygodo,
database,
following,
index,
indexcreate,
logindate,
microsoft,
mysql,
oracle,
server,
sql,
unique
Index question
Hello,
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
Thanks in advance,
sck10Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/d...-us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>sql
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
Thanks in advance,
sck10Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/d...-us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>sql
Friday, March 23, 2012
Index Question
Hi,
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add
a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
DeeThe pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)
),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
> )
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add
a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in th
e
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
>
>|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in t
he
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT|||I agree with Roy. When the index key is narrow, and the row size
relatively wide, then such a "duplicate" index could be useful for
covering queries. However, in this case the row is only 36 bytes wider
than the index key of the "duplicate" index, which is probably not even
50% larger than the key size.
Had the primary key just been one int, then IMO it would have been a
different matter. As it is, I think adding this extra index is a waste
of space and will cause unnecessary contention for
inserts/updates/deletes.
BTW: I wonder why the two "Flag" columns are defined as int, and not as
something like tinyint.
Gert-Jan
bpdee wrote:[vbcol=seagreen]
> Thanks, Roy, for your quick response! I was a bit concerned at first sinc
e
> we already have a clustered index on four of the five columns that are in
the
> non-clustered index. I thought that maybe this non-clustered index is
> considered as a "duplicate" index.
> "Roy Harvey (SQL Server MVP)" wrote:
>
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add
a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
DeeThe pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)
),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
> )
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add
a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in th
e
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
>
>|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in t
he
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT|||I agree with Roy. When the index key is narrow, and the row size
relatively wide, then such a "duplicate" index could be useful for
covering queries. However, in this case the row is only 36 bytes wider
than the index key of the "duplicate" index, which is probably not even
50% larger than the key size.
Had the primary key just been one int, then IMO it would have been a
different matter. As it is, I think adding this extra index is a waste
of space and will cause unnecessary contention for
inserts/updates/deletes.
BTW: I wonder why the two "Flag" columns are defined as int, and not as
something like tinyint.
Gert-Jan
bpdee wrote:[vbcol=seagreen]
> Thanks, Roy, for your quick response! I was a bit concerned at first sinc
e
> we already have a clustered index on four of the five columns that are in
the
> non-clustered index. I thought that maybe this non-clustered index is
> considered as a "duplicate" index.
> "Roy Harvey (SQL Server MVP)" wrote:
>
Labels:
database,
following,
index,
int,
microsoft,
mysql,
null,
nvarchar,
oracle,
projectcode,
projectresource,
resourceid,
revisionnum,
server,
sql,
table,
tablecreate
Index Question
Hi,
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
DeeThe pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
>)
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in the
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
> >Hi,
> >
> >I have the following table:
> >
> >create table ProjectResource
> >(
> > ProjectCode nvarchar(20) not null,
> > RevisionNum int not null,
> > ResourceID nvarchar(15) not null,
> > ResourceSiteURN nvarchar(128) not null,
> > ActiveFlag int not null
> > default 1
> > constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> > PrimaryFlag int not null
> > default 0
> > constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
> >(1,0)),
> > EPMProjectUID uniqueidentifier null ,
> > EPMResourceUID uniqueidentifier null ,
> > constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
> >ResourceID, ResourceSiteURN)
> >)
> >
> >You will see that the PK constraint contains the ProjectCode, RevisionNum,
> >ResourceID, and ResourceSiteURN columns. I've been given a request to add a
> >new index on the table where it contains the following columns in the order
> >they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
> >PrimaryFlag.
> >
> >What are the pros and cons of creating this new index?
> >
> >Thanks in advance,
> >Dee
>|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in the
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT|||I agree with Roy. When the index key is narrow, and the row size
relatively wide, then such a "duplicate" index could be useful for
covering queries. However, in this case the row is only 36 bytes wider
than the index key of the "duplicate" index, which is probably not even
50% larger than the key size.
Had the primary key just been one int, then IMO it would have been a
different matter. As it is, I think adding this extra index is a waste
of space and will cause unnecessary contention for
inserts/updates/deletes.
BTW: I wonder why the two "Flag" columns are defined as int, and not as
something like tinyint.
--
Gert-Jan
bpdee wrote:
> Thanks, Roy, for your quick response! I was a bit concerned at first since
> we already have a clustered index on four of the five columns that are in the
> non-clustered index. I thought that maybe this non-clustered index is
> considered as a "duplicate" index.
> "Roy Harvey (SQL Server MVP)" wrote:
> > The pro is that an index that includes no more than those five columns
> > will be covered by the non-clustered index, and will perform a bit
> > faster.
> >
> > The con is that the index takes up considerable space, and adds a
> > certain amount of overhead when rows are inserted or deleted.
> >
> > Roy Harvey
> > Beacon Falls, CT
> >
> >
> > On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> > <bpdee@.discussions.microsoft.com> wrote:
> >
> > >Hi,
> > >
> > >I have the following table:
> > >
> > >create table ProjectResource
> > >(
> > > ProjectCode nvarchar(20) not null,
> > > RevisionNum int not null,
> > > ResourceID nvarchar(15) not null,
> > > ResourceSiteURN nvarchar(128) not null,
> > > ActiveFlag int not null
> > > default 1
> > > constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> > > PrimaryFlag int not null
> > > default 0
> > > constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
> > >(1,0)),
> > > EPMProjectUID uniqueidentifier null ,
> > > EPMResourceUID uniqueidentifier null ,
> > > constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
> > >ResourceID, ResourceSiteURN)
> > >)
> > >
> > >You will see that the PK constraint contains the ProjectCode, RevisionNum,
> > >ResourceID, and ResourceSiteURN columns. I've been given a request to add a
> > >new index on the table where it contains the following columns in the order
> > >they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
> > >PrimaryFlag.
> > >
> > >What are the pros and cons of creating this new index?
> > >
> > >Thanks in advance,
> > >Dee
> >
I have the following table:
create table ProjectResource
(
ProjectCode nvarchar(20) not null,
RevisionNum int not null,
ResourceID nvarchar(15) not null,
ResourceSiteURN nvarchar(128) not null,
ActiveFlag int not null
default 1
constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
PrimaryFlag int not null
default 0
constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
(1,0)),
EPMProjectUID uniqueidentifier null ,
EPMResourceUID uniqueidentifier null ,
constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
ResourceID, ResourceSiteURN)
)
You will see that the PK constraint contains the ProjectCode, RevisionNum,
ResourceID, and ResourceSiteURN columns. I've been given a request to add a
new index on the table where it contains the following columns in the order
they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
PrimaryFlag.
What are the pros and cons of creating this new index?
Thanks in advance,
DeeThe pro is that an index that includes no more than those five columns
will be covered by the non-clustered index, and will perform a bit
faster.
The con is that the index takes up considerable space, and adds a
certain amount of overhead when rows are inserted or deleted.
Roy Harvey
Beacon Falls, CT
On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Hi,
>I have the following table:
>create table ProjectResource
>(
> ProjectCode nvarchar(20) not null,
> RevisionNum int not null,
> ResourceID nvarchar(15) not null,
> ResourceSiteURN nvarchar(128) not null,
> ActiveFlag int not null
> default 1
> constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> PrimaryFlag int not null
> default 0
> constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
>(1,0)),
> EPMProjectUID uniqueidentifier null ,
> EPMResourceUID uniqueidentifier null ,
> constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
>ResourceID, ResourceSiteURN)
>)
>You will see that the PK constraint contains the ProjectCode, RevisionNum,
>ResourceID, and ResourceSiteURN columns. I've been given a request to add a
>new index on the table where it contains the following columns in the order
>they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
>PrimaryFlag.
>What are the pros and cons of creating this new index?
>Thanks in advance,
>Dee|||Thanks, Roy, for your quick response! I was a bit concerned at first since
we already have a clustered index on four of the five columns that are in the
non-clustered index. I thought that maybe this non-clustered index is
considered as a "duplicate" index.
"Roy Harvey (SQL Server MVP)" wrote:
> The pro is that an index that includes no more than those five columns
> will be covered by the non-clustered index, and will perform a bit
> faster.
> The con is that the index takes up considerable space, and adds a
> certain amount of overhead when rows are inserted or deleted.
> Roy Harvey
> Beacon Falls, CT
>
> On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> <bpdee@.discussions.microsoft.com> wrote:
> >Hi,
> >
> >I have the following table:
> >
> >create table ProjectResource
> >(
> > ProjectCode nvarchar(20) not null,
> > RevisionNum int not null,
> > ResourceID nvarchar(15) not null,
> > ResourceSiteURN nvarchar(128) not null,
> > ActiveFlag int not null
> > default 1
> > constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> > PrimaryFlag int not null
> > default 0
> > constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
> >(1,0)),
> > EPMProjectUID uniqueidentifier null ,
> > EPMResourceUID uniqueidentifier null ,
> > constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
> >ResourceID, ResourceSiteURN)
> >)
> >
> >You will see that the PK constraint contains the ProjectCode, RevisionNum,
> >ResourceID, and ResourceSiteURN columns. I've been given a request to add a
> >new index on the table where it contains the following columns in the order
> >they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
> >PrimaryFlag.
> >
> >What are the pros and cons of creating this new index?
> >
> >Thanks in advance,
> >Dee
>|||On Tue, 13 Nov 2007 11:31:02 -0800, bpdee
<bpdee@.discussions.microsoft.com> wrote:
>Thanks, Roy, for your quick response! I was a bit concerned at first since
>we already have a clustered index on four of the five columns that are in the
>non-clustered index. I thought that maybe this non-clustered index is
>considered as a "duplicate" index.
I would not normally set up an index like that unless there was a
specific need for a covered index that it satisfied. Other than that
it really serves no purpose at all.
Roy Harvey
Beacon Falls, CT|||I agree with Roy. When the index key is narrow, and the row size
relatively wide, then such a "duplicate" index could be useful for
covering queries. However, in this case the row is only 36 bytes wider
than the index key of the "duplicate" index, which is probably not even
50% larger than the key size.
Had the primary key just been one int, then IMO it would have been a
different matter. As it is, I think adding this extra index is a waste
of space and will cause unnecessary contention for
inserts/updates/deletes.
BTW: I wonder why the two "Flag" columns are defined as int, and not as
something like tinyint.
--
Gert-Jan
bpdee wrote:
> Thanks, Roy, for your quick response! I was a bit concerned at first since
> we already have a clustered index on four of the five columns that are in the
> non-clustered index. I thought that maybe this non-clustered index is
> considered as a "duplicate" index.
> "Roy Harvey (SQL Server MVP)" wrote:
> > The pro is that an index that includes no more than those five columns
> > will be covered by the non-clustered index, and will perform a bit
> > faster.
> >
> > The con is that the index takes up considerable space, and adds a
> > certain amount of overhead when rows are inserted or deleted.
> >
> > Roy Harvey
> > Beacon Falls, CT
> >
> >
> > On Tue, 13 Nov 2007 11:02:02 -0800, bpdee
> > <bpdee@.discussions.microsoft.com> wrote:
> >
> > >Hi,
> > >
> > >I have the following table:
> > >
> > >create table ProjectResource
> > >(
> > > ProjectCode nvarchar(20) not null,
> > > RevisionNum int not null,
> > > ResourceID nvarchar(15) not null,
> > > ResourceSiteURN nvarchar(128) not null,
> > > ActiveFlag int not null
> > > default 1
> > > constraint CK_ProjectResource_ActiveFlag check (ActiveFlag in (1,0)),
> > > PrimaryFlag int not null
> > > default 0
> > > constraint CK_ProjectResource_PrimaryFlag check (PrimaryFlag in
> > >(1,0)),
> > > EPMProjectUID uniqueidentifier null ,
> > > EPMResourceUID uniqueidentifier null ,
> > > constraint PK_ProjectResource primary key (ProjectCode, RevisionNum,
> > >ResourceID, ResourceSiteURN)
> > >)
> > >
> > >You will see that the PK constraint contains the ProjectCode, RevisionNum,
> > >ResourceID, and ResourceSiteURN columns. I've been given a request to add a
> > >new index on the table where it contains the following columns in the order
> > >they are given: ProjectCode, RevisionNum, ResourceID, ResourceSiteURN,
> > >PrimaryFlag.
> > >
> > >What are the pros and cons of creating this new index?
> > >
> > >Thanks in advance,
> > >Dee
> >
Labels:
create,
database,
following,
index,
int,
microsoft,
mysql,
null,
nvarchar,
oracle,
projectcode,
projectresource,
resourceid,
revisionnum,
server,
sql,
table
Index question
I have the following index:
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
GO
Thanks for any feedback........DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Loginid] and
[logindate]). If you create the second index, may be SQL Server can decide to
use it because the key is shorter than the first one, so more rows can fit in
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
> >I have the following index:
> >
> > CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> > logindate]) ON [PRIMARY]
> > GO
> >
> > Do I still need to create the following index ?
> >
> >
> > CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> > GO
> >
> >
> > Thanks for any feedback........
>
>sql
CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
logindate]) ON [PRIMARY]
GO
Do I still need to create the following index ?
CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
GO
Thanks for any feedback........DXC,
SQL Server stores statistics for the more left column in the key. This index
could be used for logic expressions referencing [Loginid] or ([Loginid] and
[logindate]). If you create the second index, may be SQL Server can decide to
use it because the key is shorter than the first one, so more rows can fit in
a page and less IO operations will be required.
Try some "select" statements with just the first index. If you are ok with
the response time and execution plan selected by SQL Server then do not
create the second one. Remember, indexes help sql server to find the data
faster, but also put more load for insert, delete, and update operations.
AMB
"DXC" wrote:
> I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
on Loginid
"DXC" <DXC@.discussions.microsoft.com> wrote in message
news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
>I have the following index:
> CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> logindate]) ON [PRIMARY]
> GO
> Do I still need to create the following index ?
>
> CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> GO
>
> Thanks for any feedback........|||That's what I thought............Thanks.
"Paul Wehland" wrote:
> No. MYINDEX2 is redundant. SQL Server can use MYINDEX1 if it needs to seek
> on Loginid
>
> "DXC" <DXC@.discussions.microsoft.com> wrote in message
> news:34A7F75B-5178-4DD1-BD31-AFEE69C13458@.microsoft.com...
> >I have the following index:
> >
> > CREATE UNIQUE INDEX [MYINDEX1] ON [dbo].[LOGIN_TABLE]([Loginid],
> > logindate]) ON [PRIMARY]
> > GO
> >
> > Do I still need to create the following index ?
> >
> >
> > CREATE INDEX [MYINDEX2] ON [dbo].[LOGIN_TABLE]([Loginid]) ON [PRIMARY]
> > GO
> >
> >
> > Thanks for any feedback........
>
>sql
Index question
Hello,
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
--
Thanks in advance,
sck10Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
--
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>
I have a telephone log table that tracks the following: (phone number, time
of day, duration of call). This table that is populated with over 1/2 a
million telephone numbers per day. My question is what is the appropriate
way of indexing a table with this volume of inserts?
--
Thanks in advance,
sck10Something like that usually does well with a clustered index on the datetime
but it depends on how you need to access the data. What are your typical
queries like?
--
Andrew J. Kelly SQL MVP
"sck10" <sck10@.online.nospam> wrote in message
news:uTER80kzEHA.3656@.TK2MSFTNGP09.phx.gbl...
> Hello,
> I have a telephone log table that tracks the following: (phone number,
> time
> of day, duration of call). This table that is populated with over 1/2 a
> million telephone numbers per day. My question is what is the appropriate
> way of indexing a table with this volume of inserts?
> --
> Thanks in advance,
> sck10
>|||Hi sck10,
Addtionally to MVP Andrew J. Kelly's suggestions, you would also make the
decision based on Index Tuning Wizard in Query Analyzer. Here is some
guidelines for you
Index Tuning Wizard for Microsoft SQL Server 2000
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/htm
l/itwforsql.asp
INF: Index Tuning Wizard Best Practices
http://support.microsoft.com/kb/311826
Support WebCast: Effective Indexing and Statistics with SQL 2000
http://support.microsoft.com/kb/325024
Hope this helps and if you have any questions or concerns, don't hesitate
to let me know. We are always here to be of assistance!
Sincerely yours,
Michael Cheng
Online Partner Support Specialist
Partner Support Group
Microsoft Global Technical Support Center
---
Get Secure! - http://www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks!|||It depends on whether this data is being inserted in real time
or if the data is loaded from provider files, and also on whether
the data is constantly being queried, or if it is only accessed for
occasional reports and bill generation. If it's bulk loaded
from provider files, or if it's processed only for reports and
bills, you have more flexibility, and can index it in a way
that's useful to what you do with the data. If it's loaded
in real time, but not queried in real time, it could even be
appropriate to load it into an unindexed table, or into
a table with an artificial clustered key like a column with
the identity property. If the hardware cannot spit
out the same call twice, you don't need a natural key while
the data is loading.
Can you say more about where this data comes from,
what kinds of queries you run against it, and whether
there are typically few or many connections querying
the data at once?
Steve Kass
Drew University
sck10 wrote:
>Hello,
>I have a telephone log table that tracks the following: (phone number, time
>of day, duration of call). This table that is populated with over 1/2 a
>million telephone numbers per day. My question is what is the appropriate
>way of indexing a table with this volume of inserts?
>
>
Index Problem?
If a table has corrupted indexes, can I still query against it in SQL Enterprise?
I have the following statement as the data source of my data list.
SELECT productid, prodname, prodprice from products inner join vendors on products.vendorid = vendors.vendorid where vendorid = 185
The data list takes long time to populate and returns no row. I thought maybe the index of my Products table got corrupted, so I ran the same statement in SQL statement and got 3 rows of data. I am clueless now. Any suggestion?
Thanks
Bugme.Sounds to me the table is locked or at least a few rows.
on the side: I'd expect something like "Ambiguous column name 'vendorid '."|||Can you look at the sticky and post some more info.
Have you tried DBCC CHECKTABLE?
And what do you mean SQL Enterprise?
Space...the final frontier......|||It's the Enterprise Manager.
I ran DBCC CHECKTABLE and got the following --
There are 8832 rows in 82 pages for object 'products'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Since I didn't get any error from DBCC CHECKTABLE, does it mean that the index on products table is fine?
If the table is locked, how can I unlock it?
Thanks
SHK|||The EM might do the locking, I'm not sure how it's used. What happens if you'd exit the EM, run the SQL Analyzer?|||I am not sure I understand where you are going with the question. Theoretically, you can query a table that has corrupt non-clustered indexes, so long as you are not using the corrupt index to access the table. Is your base problem that the query is just slow?|||ProductID is the clustered indexed field and I tried to query against ProductID in EM, I got data.
The problem is when I run the query in my application, it returns no data. When I run the same query in EM, I get data. The problem only happens to vendorid 185. If I run the application with different vendorid, it works just fine. I checked the index on the vendors table too and it's fine.
Weird! Help.
SHK.|||Well, we can rule out miracles. Post the exact query from the .asp page, and the query you run from Query Analyzer. I expect a join has been fouled up, or the where clause in the .asp page is more involved.
I have the following statement as the data source of my data list.
SELECT productid, prodname, prodprice from products inner join vendors on products.vendorid = vendors.vendorid where vendorid = 185
The data list takes long time to populate and returns no row. I thought maybe the index of my Products table got corrupted, so I ran the same statement in SQL statement and got 3 rows of data. I am clueless now. Any suggestion?
Thanks
Bugme.Sounds to me the table is locked or at least a few rows.
on the side: I'd expect something like "Ambiguous column name 'vendorid '."|||Can you look at the sticky and post some more info.
Have you tried DBCC CHECKTABLE?
And what do you mean SQL Enterprise?
Space...the final frontier......|||It's the Enterprise Manager.
I ran DBCC CHECKTABLE and got the following --
There are 8832 rows in 82 pages for object 'products'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator.
Since I didn't get any error from DBCC CHECKTABLE, does it mean that the index on products table is fine?
If the table is locked, how can I unlock it?
Thanks
SHK|||The EM might do the locking, I'm not sure how it's used. What happens if you'd exit the EM, run the SQL Analyzer?|||I am not sure I understand where you are going with the question. Theoretically, you can query a table that has corrupt non-clustered indexes, so long as you are not using the corrupt index to access the table. Is your base problem that the query is just slow?|||ProductID is the clustered indexed field and I tried to query against ProductID in EM, I got data.
The problem is when I run the query in my application, it returns no data. When I run the same query in EM, I get data. The problem only happens to vendorid 185. If I run the application with different vendorid, it works just fine. I checked the index on the vendors table too and it's fine.
Weird! Help.
SHK.|||Well, we can rule out miracles. Post the exact query from the .asp page, and the query you run from Query Analyzer. I expect a join has been fouled up, or the where clause in the .asp page is more involved.
Index problem
this my script
CREATE UNIQUE INDEX [RELBFM].[UQ_PMT_PMTNAME] ON [RELBFM]. [ISMPMT] ("PMTNAME" ASC);
following errors occur
where i am facing problemSyntax for a create index statement:CREATE UNIQUE NONCLUSTERED INDEX ix_t_name_c_name_nu_nc
ON schema_name.t_name (c_name ASC)
Spot the diff ;)|||The original is correct for Oracle, but indexes in SQL Server are assumed to be part of the table's schema. In fact, the "index owner" is not even a concept in SQL Server.|||[QUOTE=pootle flump]Syntax for a create index statement:CREATE UNIQUE NONCLUSTERED INDEX ix_t_name_c_name_nu_nc
ON schema_name.t_name (c_name ASC)
Spot the diff ;) [/QUOso
so when we use CLUSTERED AND NONCLUSTERED INDEX
I had used clustered primary key so what type of index should I use|||Actually the clustered\ nonclustered bit is not mandatory. I just like to put it in so it is explicit. It also appears that there was a copy and paste problem (apologies) - there should be a space between nonclustered and index. The difference was actually as mcrowley said - you "qualified" the index name when you should not have.
A pk and a not null unique index are exactly the same as far as sql server is concerned.
CREATE UNIQUE INDEX [RELBFM].[UQ_PMT_PMTNAME] ON [RELBFM]. [ISMPMT] ("PMTNAME" ASC);
following errors occur
where i am facing problemSyntax for a create index statement:CREATE UNIQUE NONCLUSTERED INDEX ix_t_name_c_name_nu_nc
ON schema_name.t_name (c_name ASC)
Spot the diff ;)|||The original is correct for Oracle, but indexes in SQL Server are assumed to be part of the table's schema. In fact, the "index owner" is not even a concept in SQL Server.|||[QUOTE=pootle flump]Syntax for a create index statement:CREATE UNIQUE NONCLUSTERED INDEX ix_t_name_c_name_nu_nc
ON schema_name.t_name (c_name ASC)
Spot the diff ;) [/QUOso
so when we use CLUSTERED AND NONCLUSTERED INDEX
I had used clustered primary key so what type of index should I use|||Actually the clustered\ nonclustered bit is not mandatory. I just like to put it in so it is explicit. It also appears that there was a copy and paste problem (apologies) - there should be a space between nonclustered and index. The difference was actually as mcrowley said - you "qualified" the index name when you should not have.
A pk and a not null unique index are exactly the same as far as sql server is concerned.
Index -Pls Help-
hi
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
Dil
Hi all
I hope am in the right group.
IF NO
Pls let me know
Dil
|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename>) AND
name =3D <IndexName>=20
HTH, jens Suessmeyer.
|||Hi
Thank u So much Jens For u help
Dil
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
Dil
Hi all
I hope am in the right group.
IF NO
Pls let me know
Dil
|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename>) AND
name =3D <IndexName>=20
HTH, jens Suessmeyer.
|||Hi
Thank u So much Jens For u help
Dil
Index -Pls Help-
hi
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
DilHi all
I hope am in the right group.
IF NO
Pls let me know
Dil|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename>) AND
name =3D <IndexName>
HTH, jens Suessmeyer.|||Hi
Thank u So much Jens For u help
Dil
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
DilHi all
I hope am in the right group.
IF NO
Pls let me know
Dil|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename>) AND
name =3D <IndexName>
HTH, jens Suessmeyer.|||Hi
Thank u So much Jens For u help
Dil
Index -Pls Help-
hi
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
DilHi all
I hope am in the right group.
IF NO
Pls let me know
Dil|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename> ) AND
name =3D <IndexName>=20
HTH, jens Suessmeyer.|||Hi
Thank u So much Jens For u help
Dil
I have used the following query for checking whether an index is
existing or not
SELECT name FROM sysindexes WHERE name = 'TESTINDEX'
This will return all indexes name 'TESTINDEX'
if the database contains 10 indexes named as 'testindex' it will show
all.
so how can I select an index which is associated with a particular
table.
Actually I want to run this query
USE db1
IF EXISTS (SELECT name FROM sysindexes WHERE name = 'TESTINDEX') DROP
INDEX MyTable.TESTINDEX
The IF EXISTS clause wil return true, if there is any other index have
the same name as TESTINDEX
Then when I try to delete It will show an error (Because MyTable does
not contains TESTINDEX)
How can I solve this issue
Pls help
Thanks in Advance
DilHi all
I hope am in the right group.
IF NO
Pls let me know
Dil|||Sorry, didn=B4t see your post:
select * from sysindexes
where
id =3D OBJECT_ID(<Tablename> ) AND
name =3D <IndexName>=20
HTH, jens Suessmeyer.|||Hi
Thank u So much Jens For u help
Dil
Wednesday, March 21, 2012
Index out of range error exporting to Excel
i've noticed that others have gotten this same error, when trying to
export to excel they get the following error, it seems it hasn't been
something dealt with, maybe because microsoft cannot reproduce it
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException
was thrown. (rrRenderingError) Get Online Help
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException
was thrown.
Index was out of range. Must be non-negative and less than the size of
the collection. Parameter name: index
I am using SP2 and this error is happening both in the report designer
as well as in reporting services itself.
my situation.. i have a report.. with grouped data, inside the footer
of one of the groups i put a table, then in that nested table i have a
group, and in the group footer of that i have a line with the field i
am grouping on as well as a sum.. at first i thought maybe it had to do
with something that i hide the detail, and group header of the nested
table, but i showed that it it still failed..
one thing that made it work, was when i moved this nested table out of
the group footer of the parent table, and into the footer of the nested
table, when i did that the error no longer happened (however i need to
be able to have it in this group)..
if you need some examples maybe i can adapt my report (take out our
business specific info) and send it on to you.
Karl
the error only happens when exporting to excel..correction below:
one thing that made it work, was when i moved this nested table out of
the group footer IN THE PARENT TABLE of the parent table, and into the
footer of the PARENT
table, when i did that the error no longer happened (however i need to
be able to have it in this group)..
export to excel they get the following error, it seems it hasn't been
something dealt with, maybe because microsoft cannot reproduce it
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException
was thrown. (rrRenderingError) Get Online Help
Exception of type
Microsoft.ReportingServices.ReportRendering.ReportRenderingException
was thrown.
Index was out of range. Must be non-negative and less than the size of
the collection. Parameter name: index
I am using SP2 and this error is happening both in the report designer
as well as in reporting services itself.
my situation.. i have a report.. with grouped data, inside the footer
of one of the groups i put a table, then in that nested table i have a
group, and in the group footer of that i have a line with the field i
am grouping on as well as a sum.. at first i thought maybe it had to do
with something that i hide the detail, and group header of the nested
table, but i showed that it it still failed..
one thing that made it work, was when i moved this nested table out of
the group footer of the parent table, and into the footer of the nested
table, when i did that the error no longer happened (however i need to
be able to have it in this group)..
if you need some examples maybe i can adapt my report (take out our
business specific info) and send it on to you.
Karl
the error only happens when exporting to excel..correction below:
one thing that made it work, was when i moved this nested table out of
the group footer IN THE PARENT TABLE of the parent table, and into the
footer of the PARENT
table, when i did that the error no longer happened (however i need to
be able to have it in this group)..
Subscribe to:
Posts (Atom)