Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Friday, March 30, 2012

INFORMATION_SCHEMA.PARAMETERS

Is anybody able to access system tables used by INFORMATION_SCHEMA.PARAMETERS?

Namely: sys.sysscalartypes, sys.sysschobjs and sys.syscolpars.

A select on any of these failes with 'Invalid object name'

These are system base tables that are used by the database engine only.

Please see http://msdn2.microsoft.com/en-us/library/ms179503.aspx

Is there a reason why you would want to access these base tables ?

|||Curiosity really...

INFORMATION_SCHEMA.PARAMETERS

Is anybody able to access system tables used by INFORMATION_SCHEMA.PARAMETERS?

Namely: sys.sysscalartypes, sys.sysschobjs and sys.syscolpars.

A select on any of these failes with 'Invalid object name'

These are system base tables that are used by the database engine only.

Please see http://msdn2.microsoft.com/en-us/library/ms179503.aspx

Is there a reason why you would want to access these base tables ?

|||Curiosity really...

INFORMATION_SCHEMA.COLUMNS query

Hi,
I'm trying to run the following query but keep getting an error
returned:
SELECT COUNT(*)FROM
[sever_name].[database_name].INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = '[table_name]'
Error:
Server: Msg 7314, Level 16, State 1, Line 2
OLE DB provider '[sever_name]' does not contain table
'"[database_name]"."INFORMATION_SCHEMA"."COLUMNS"'. The table either
does not exist or the current user does not have permissions on that
table.
OLE DB error trace [Non-interface error: OLE DB provider does not
contain the table: ProviderName='[sever_name]',
TableName='"[database_name]"."INFORMATION_SCHEMA"."COLUMNS"'].
The table does exist and the other server has been added to the
sysservers table and works as other queries can be run. I've run the
exact code on other sql servers and it works without any problems. Any
help to run this query would be much appreciated.
Thanks
SimonAFAIK, you can't use the information_schema views in SQL Server 2000 from a linked server as they
don't exists in each database, they only exist in the master database. Use syscolumns etc instead.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"accyboy1981" <accyboy1981@.gmail.com> wrote in message
news:1129802634.977349.10700@.g14g2000cwa.googlegroups.com...
> Hi,
> I'm trying to run the following query but keep getting an error
> returned:
> SELECT COUNT(*)FROM
> [sever_name].[database_name].INFORMATION_SCHEMA.COLUMNS
> WHERE TABLE_NAME = '[table_name]'
> Error:
> Server: Msg 7314, Level 16, State 1, Line 2
> OLE DB provider '[sever_name]' does not contain table
> '"[database_name]"."INFORMATION_SCHEMA"."COLUMNS"'. The table either
> does not exist or the current user does not have permissions on that
> table.
> OLE DB error trace [Non-interface error: OLE DB provider does not
> contain the table: ProviderName='[sever_name]',
> TableName='"[database_name]"."INFORMATION_SCHEMA"."COLUMNS"'].
> The table does exist and the other server has been added to the
> sysservers table and works as other queries can be run. I've run the
> exact code on other sql servers and it works without any problems. Any
> help to run this query would be much appreciated.
> Thanks
> Simon
>

INFORMATION_SCHEMA.COLUMNS error

Hi All,

For some reason, whenever I execute the following query:

SELECT * FROM INFORMATION_SCHEMA.COLUMNS

I get a few rows returned then I get the following error:

Server: Msg 8115, Level 16, State 2, Line 1
Arithmetic overflow error converting expression to data type int.

Is my INFORMATION_SCHEMA.COLUMNS view corrupt somehow?

Querries of other INFORMATION_SCHEMA views are fine, just this one is returning an error. Anyone have any ideas about how to fix this?

John

Can you post the table structure..|||

Manivannan.D.Sekaran wrote:

Can you post the table structure..

The table structure of what? The INFORMATION_SCHEMA.COLUMNS view? This is the default INFORMATION_SCHEMA.COLUMNS view that is created by default in SQL Server. Its what should be there by default. Its not a view that I've created.

So what table structure are you referring to?

John

|||

Ohh yes.. You dont know which table cause the problem.. Simply forget..

Ok try to execute the following query..

At one time you will get an error.. So that is the table causing the issue... Then post the DDL of that table...

sp_msforeachtable'Print ''? is Executing..'';Select Count(Column_Name) TotalColumn, ''?'' TableName fromINFORMATION_SCHEMA.COLUMNS Where object_id(table_name) = object_id(''?'');Print ''? is Completed..'';'

|||

Hi Manivannan,

Ok I executed your query. I didn't get any errors.

I think the issue is with the view in general on my server. I get the error when I execute the query against INFORMATION_SCHEMA.COLUMNS regardless of the database I execute against.

When I execute your script against ALL of my databases (on my server) I get no errors.

|||

Here's a little background on what I think may have caused my server to be in such a state.

I have been tasked with changing all columns, in all tables, in our database that are of varchar type to be nvarchar. I immediately issued a query such as

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE DATA_TYPE='varchar'

That very simply returned ALL columns in my database that were of varchar type, I think there were hundreds of rows returned. So, I think this is what screwed things up for me, I executed an update statement against that view as a test to see if I could do such a thing. This is the update statement I executed:

UPDATE INFORMATION_SCHEMA.COLUMNS SET DATA_TYPE='nvarchar' WHERE DATA_TYPE='varchar'

I figured something was wrong when upon executing that statement it said that 1 row was updated. I got no error message, but now all querries of that view yields the error I documented.

|||

Its really worst idea changing the system tables directly. You should use the proper alter statement.

The update query you performed, is modified the data in System Table (spt_datatype_info) rather than your original table (on syscolumns).

If you only executed the above query then use the following query to revert back spt_datatype_info into original state..

UPDATE spt_datatype_info

SET local_type_name=type_name

WHERE local_type_name='varchar'

|||

WooHoo, it worked!

I changed your update statement slightly to:

UPDATE spt_datatype_info
SET local_type_name=type_name
WHERE local_type_name!=type_name

It restored all that were messed up (there were two rows actually, the row for "varchar" and the row for "text").

Thank you very much Manivannan!

John

sql

Information_Schema Question

Hi
I am selecting some column info from information_schema like this:
SELECT COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,IS_NULLABLE
FROM test.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = N'Test Table';
I am doing this via OleDb connection to Sql2000
I connect as the owner of the database/tables.
I connect to the database for which I am seeking the information
('test').
I get rows returned for some tables, but not others. At first, when I
test in query analyzer (connected as same user) I got the same
results. So then, I went to Enterprise Manager and looked at
permissions for the tables for which I was getting no data returned.
There were no permissions on the tables at all. If I added, just/only
SELECT permission for this user, then I get results in query analyzer.
Ah ha, I think, I have it! So now I go back to my application and try
again with the OleDb connection and, well, it works for some tables
now (for which it did not earlier) , but there are still other tables
that , although they now return column information in Query Analyser,
still do not return any column information from my OleDb connection
query.
Is this a permissions issue with the table itself?
What else should I be looking for in my database that could be
preventing this column information from being returned to the user via
the connection? Is it the connection?
Thanks
JeffNobody has any idea what I might be missing here?
Jeff
On Thu, 22 Dec 2005 06:58:10 GMT, Jeff User <jeff31162@.hotmail.com>
wrote:
>Hi
>I am selecting some column info from information_schema like this:
>SELECT COLUMN_NAME,DATA_TYPE,CHARACTER_MAXIMUM_LENGTH,IS_NULLABLE
>FROM test.INFORMATION_SCHEMA.COLUMNS
>WHERE TABLE_NAME = N'Test Table';
>I am doing this via OleDb connection to Sql2000
>I connect as the owner of the database/tables.
>I connect to the database for which I am seeking the information
>('test').
>I get rows returned for some tables, but not others. At first, when I
>test in query analyzer (connected as same user) I got the same
>results. So then, I went to Enterprise Manager and looked at
>permissions for the tables for which I was getting no data returned.
>There were no permissions on the tables at all. If I added, just/only
>SELECT permission for this user, then I get results in query analyzer.
>Ah ha, I think, I have it! So now I go back to my application and try
>again with the OleDb connection and, well, it works for some tables
>now (for which it did not earlier) , but there are still other tables
>that , although they now return column information in Query Analyser,
>still do not return any column information from my OleDb connection
>query.
>Is this a permissions issue with the table itself?
>What else should I be looking for in my database that could be
>preventing this column information from being returned to the user via
>the connection? Is it the connection?
>Thanks
>Jeff

Wednesday, March 28, 2012

information inside a function

Hiii

How can i know, when i'm inside a function, what tables are in the select

if my select is:

select myfunction(x)

from table1

I want to know inside myfunction that the table is table1

is there a way of knowing that?

thanks

One way that I can think of to do this is to perform a SET CONTEXT_INFO before calling your scalar UDF and then using the CONTEXT_INFO function from within the context of the UDF. Another potential is to load the information into a permanent table; however, this will require some thought to avoid collisions with other users. This doesn't sound like a real good idea; how are you planning on using this information?

Kent

The better answer / question is why can't you pass this information as an argument to the function?

|||

thanks for the quick answer

The function has to use a select statement which uses the same table and return a value related to it.

this functions will be used by a different user and i dont want the user to type a lot of input parameters.

|||

Hi snorman,

Can you expand what you are trying to accomplish here?

AMB

INFOMRATION_SCHEMA.COLUMNS question

I have a script that is looking at
IF NOT EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Security_Code_DE'
AND COLUMN_NAME = 'ActiveProductBitMap')
I can see in enterprise manager that the db I restored does not have a
column ActiveProductBitMap, nor should it. The db before restore did. I must
have taken some sequence of steps to fail to update the master db. But I
don't know what that would be, since I know very little about the master db.
How does the master db keep track of schema on restore? ThanksI'm not sure what you asking here...

> I can see in enterprise manager that the db I restored does not have a
> column ActiveProductBitMap, nor should it.
... OK.

> The db before restore did.
Which database? The one you just restore onto? If so, that is overwritten by
a restore operation.
I fail to see what the master database has to do this this. Can you elaborat
e?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Stephanie" <IwishICould@.NoWay.com> wrote in message news:erbEsWLqFHA.3520@.tk2msftngp13.phx
.gbl...
>I have a script that is looking at
> IF NOT EXISTS ( SELECT *
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE TABLE_NAME = 'Security_Code_DE'
> AND COLUMN_NAME = 'ActiveProductBitMap')
> I can see in enterprise manager that the db I restored does not have a
> column ActiveProductBitMap, nor should it. The db before restore did. I mu
st
> have taken some sequence of steps to fail to update the master db. But I
> don't know what that would be, since I know very little about the master d
b.
> How does the master db keep track of schema on restore? Thanks
>|||"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23%23ix%23jLqFHA.1324@.tk2msftngp13.phx.gbl...
> I'm not sure what you asking here...
>
> ... OK.
>
> Which database? The one you just restore onto? If so, that is overwritten
> by a restore operation.
>
Yes.

> I fail to see what the master database has to do this this. Can you
> elaborate?
These views (INFOMRATION_SCHEMA) are supposed to reflect the schema of the
db. The db guy here is telling me that during a restore SQL server updates
the information in master to reflect the schema of the db as restored. This
is not what I am seeing. Since scripts that run are accessing information in
the INFORMATION_SCHEMA views, the underlying data about the schema should
reflect the schema as it currently exists in the db.
So, is the db guy wrong, and the restore process does not update the schema
info stored in master? Or is there a proper way to do the restore such that
the schema info is reflected properly?
Thanks.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Stephanie" <IwishICould@.NoWay.com> wrote in message
> news:erbEsWLqFHA.3520@.tk2msftngp13.phx.gbl...|||> These views (INFOMRATION_SCHEMA) are supposed to reflect the schema of the db. The db guy
here is
> telling me that during a restore SQL server updates the information in mas
ter to reflect the
> schema of the db as restored.
That makes no sense at all to me. Seems to me like that person doesn't know
SQL Server very well or
that the person didn't explain very well.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Stephanie" <IwishICould@.NoWay.com> wrote in message news:%239UvRsLqFHA.3136@.TK2MSFTNGP11.p
hx.gbl...
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:%23%23ix%23jLqFHA.1324@.tk2msftngp13.phx.gbl...
> Yes.
>
> These views (INFOMRATION_SCHEMA) are supposed to reflect the schema of the
db. The db guy here is
> telling me that during a restore SQL server updates the information in mas
ter to reflect the
> schema of the db as restored. This is not what I am seeing. Since scripts
that run are accessing
> information in the INFORMATION_SCHEMA views, the underlying data about the
schema should reflect
> the schema as it currently exists in the db.
> So, is the db guy wrong, and the restore process does not update the schem
a info stored in master?
> Or is there a proper way to do the restore such that the schema info is re
flected properly?
> Thanks.
>
>|||"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:eA23TqMqFHA.2416@.TK2MSFTNGP14.phx.gbl...
> That makes no sense at all to me. Seems to me like that person doesn't
> know SQL Server very well or that the person didn't explain very well.
>
How does one get the master database to reflect the actual schema of a
restored db? I, for one, don't know the internals of Sql Server At All. And
I am having trouble finding anything other than transact sql reference to
this information. Or am I missing the point of these views?
Thanks.

> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Stephanie" <IwishICould@.NoWay.com> wrote in message
> news:%239UvRsLqFHA.3136@.TK2MSFTNGP11.phx.gbl...
>|||I don't know what schema you refer to. The database schema is contained *ins
ide* the database, not
in master.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Stephanie" <IwishICould@.NoWay.com> wrote in message news:%23MbBC0MqFHA.2696@.TK2MSFTNGP11.p
hx.gbl...
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n message
> news:eA23TqMqFHA.2416@.TK2MSFTNGP14.phx.gbl...
> How does one get the master database to reflect the actual schema of a res
tored db? I, for one,
> don't know the internals of Sql Server At All. And I am having trouble fin
ding anything other than
> transact sql reference to this information. Or am I missing the point of t
hese views?
> Thanks.
>
>|||> How does one get the master database to reflect the actual schema of a
> restored db?
The master database knows very little about the schema of user databases.
These are stored in the user databases and, in the case of a database
restore, the backup file contains this information, not master. This is why
you can backup a database on one server, and restore it on another (whose
master database, obviously, has absolutely no knowledge of the new
database).
So perhaps, instead of trying to "get the master database to reflect"
anything, you need to describe exactly what you are trying to accomplish.
A|||"Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in message
news:%23kw704MqFHA.2956@.TK2MSFTNGP12.phx.gbl...
> The master database knows very little about the schema of user databases.
> These are stored in the user databases and, in the case of a database
> restore, the backup file contains this information, not master. This is
> why you can backup a database on one server, and restore it on another
> (whose master database, obviously, has absolutely no knowledge of the new
> database).
> So perhaps, instead of trying to "get the master database to reflect"
> anything, you need to describe exactly what you are trying to accomplish.
> A
>
I am looking at a script with
IF NOT EXISTS ( SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Security_Code_DE'
AND COLUMN_NAME = 'ActiveProductBitMap')
This condition is returning true. If I do select * from
information_schema.columns... I see a row. If I right click on the table in
Enterprise manager, and select design, I do not see this column. This is a
problem for me.|||> information_schema.columns... I see a row. If I right click on the table
> in Enterprise manager, and select design, I do not see this column. This
> is a problem for me.
And what do you see when you open Query Analyzer, hit F8, go down to the
table, expand, and expand the Columns node? Is your phantom column there
are not?|||> I am looking at a script with
> IF NOT EXISTS ( SELECT *
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE TABLE_NAME = 'Security_Code_DE'
> AND COLUMN_NAME = 'ActiveProductBitMap')
> This condition is returning true. If I do select * from information_schema
.columns... I see a row.
> If I right click on the table in Enterprise manager, and select design, I
do not see this column.
> This is a problem for me.
Perhaps it is only a matter of refresh in EM? Or could you have two tables w
ith the same name but
different owners?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Stephanie" <IwishICould@.NoWay.com> wrote in message news:%23hJBdkNqFHA.3724@.TK2MSFTNGP12.p
hx.gbl...
> "Aaron Bertrand [SQL Server MVP]" <ten.xoc@.dnartreb.noraa> wrote in messag
e
> news:%23kw704MqFHA.2956@.TK2MSFTNGP12.phx.gbl...
> I am looking at a script with
> IF NOT EXISTS ( SELECT *
> FROM INFORMATION_SCHEMA.COLUMNS
> WHERE TABLE_NAME = 'Security_Code_DE'
> AND COLUMN_NAME = 'ActiveProductBitMap')
> This condition is returning true. If I do select * from information_schema
.columns... I see a row.
> If I right click on the table in Enterprise manager, and select design, I
do not see this column.
> This is a problem for me.
>

Friday, March 23, 2012

Inequality Comparision on Dimension members

Hi,

Take foodmart sales cube as an example, I want to find out store sizes that are bigger than 35000. I have tried.

1. select filter([Store Size in SQFT].[Store Sqft].members, STRTOVALUE([Store Size in SQFT].currentmember.name) > 35000) on columns from sales

Output: An MDX expression was expected. An empty expression was specified.

2.

select filter([Store Size in SQFT].[Store Sqft].members, [Store Size in SQFT].currentmember.name > '35000')

on columns from sales

Output: lexicological comparison, not what I want.

3.

select filter([Store Size in SQFT].[Store Sqft].members, [Store Size in SQFT].currentmember > 30000) on columns from sales

Output: comparing with default measure instead.

I guess I am still having the SQL mindset. Any help is really appreciated.

Hi

you should use function Val in order to convert string property into number.

select
filter([Store Size in SQFT].[Store Sqft].members, Val([Store Size in SQFT].currentmember.name) > 35000)
on columns
from sales

sql

Ineed the Right Syntax

Hello,

I need the Right Syntax of this Staement

IF(select count(*) from Department where Department_Id=@.De_Id)=0

begin

insert into Depatment vaule.....etc

esle

update

end

just i have problem with the syntax of first If Statement

Something like this would be a bit more efficient.

Searching stops when the first row is encountered, whereas SELECT count(*) has to search the entire filtered set.

Also, 'IF' does not require an 'END' as in Visual Basic.

Code Snippet

IF EXISTS

( SELECT 1

FROM Department

WHERE Department_ID = @.De_ID

)

INSERT INTO Department ( Columns )

VALUES ( @.Values )

ELSE

UPDATE Department

SET

Column1 = @.Value1,

etc.

|||

For anyone who is currently doing the first touch to the new version of SQL Server 2008, you should try the MERGE statement (aka UPSERT) which was requested for many of the previous version and is finally implemented.

Jens K. Suessmeyer.


http://www.sqlserver2005.de

Monday, March 12, 2012

indexing

Hi,
There is a table which I regularly run a select query on.
The select query always has a fixed where clause on only three of the columns with different parameters.

This is a query that runs each time:

select * from tblData
where
PersonNo = 2 and EmployeeType = 4 and DataDate = getdate()

This are the types of indexes the table currently has:
One index for each of these three fields
i.e. index1 for PersonNo
index2 for EmployeeType
index3 for DataDate
In addition to the above, I also have created a covering index as follows
index4 for PersonNo,EmployeeType,DataDate

Is what I have enough for indexes on this table please?
Is there anything else I have to do on indexing this table?
Thanks

Indexing is a big subject. At a base level, you should index those columns that will be queried most often, in the order that they are most often queried. That being said, there's a lot more to learn. Here's some beginning info, which has pointers to more advanced concepts:

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=200&rl=1

|||I am baffled by the DataDate = getdate(); I am surprised that this works; is this just something you meant generically or are you really searching like this?

Wednesday, March 7, 2012

Indexes on Joined Columns

I have the following select statement used to create a view:
select
st.col1,
st.col2
from
FirstTable ft
inner join
SecondTable st
on
ft.coluid = st.colfid
and
ft.colkey = st.colkey
My statistics are up to date.
On FirstTable I have a clustered (Unique) primary key comprised of a
composite of coluid and colkey (in that order) having 64,000 rows. Column
coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio of
0.
On SecondTable I have a clustered (non unique) primary key comprised of a
composite of colfid and colkey (in that order) having 168,000 rows. Column
colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio of
0.
The two columns returned (st.col1, st.col2) from the select statement are not
indexed.
I was under the impression from various readings that having indexes on joins
are beneficial, but in testing, when I have the clustered indexes, versus
dropping the indexes and running the select statement, there is no difference
in the output of statistics io.
Also the execution plan states that each table receives a clustered index
scan.
The only benefit I see from having indexes on the joins is in CPU time, with
indexes 187 ms., without 375 ms.
Is that the benefit (reduced CPU, but no reduction of Logical Reads) spoken
of when I read that indexes on joined columns are beneficial? Also, wouldn't
my two columns returned be covered by the clustered index, if the index were
ever used?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1Um, basically, you want the entire contents of both tables. How about
filtering in some way? Also. if you are using SQL Server 2000, try adding
clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
SQL 2005, create the nonclustered on (st.col1, st.col2) with included
columns on (st.colfid, st.colkey).
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:60c001bcd2645@.uwe...
I have the following select statement used to create a view:
select
st.col1,
st.col2
from
FirstTable ft
inner join
SecondTable st
on
ft.coluid = st.colfid
and
ft.colkey = st.colkey
My statistics are up to date.
On FirstTable I have a clustered (Unique) primary key comprised of a
composite of coluid and colkey (in that order) having 64,000 rows. Column
coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio of
0.
On SecondTable I have a clustered (non unique) primary key comprised of a
composite of colfid and colkey (in that order) having 168,000 rows. Column
colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio of
0.
The two columns returned (st.col1, st.col2) from the select statement are
not
indexed.
I was under the impression from various readings that having indexes on
joins
are beneficial, but in testing, when I have the clustered indexes, versus
dropping the indexes and running the select statement, there is no
difference
in the output of statistics io.
Also the execution plan states that each table receives a clustered index
scan.
The only benefit I see from having indexes on the joins is in CPU time, with
indexes 187 ms., without 375 ms.
Is that the benefit (reduced CPU, but no reduction of Logical Reads) spoken
of when I read that indexes on joined columns are beneficial? Also, wouldn't
my two columns returned be covered by the clustered index, if the index were
ever used?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1|||A clustered index scan is a table scan, so that is no surprise.
You cannot use statistics IO to tell which is the better plan. As you have
noticed, the IO is the same, but the CPU is different. What kind of join
does the plan say is being performed? Without indexes, my guess is that
you're getting a hash join, which does a single pass through each table
while it builds and analyzes hash lists. So the IO is only one pass through
each table. But the extra work of building and examining the hash lists, but
the extra memory required to stored the hashed information, can make that
type of join very resource intensive.
--
HTH
Kalen Delaney, SQL Server MVP
"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:60c001bcd2645@.uwe...
>I have the following select statement used to create a view:
> select
> st.col1,
> st.col2
> from
> FirstTable ft
> inner join
> SecondTable st
> on
> ft.coluid = st.colfid
> and
> ft.colkey = st.colkey
> My statistics are up to date.
> On FirstTable I have a clustered (Unique) primary key comprised of a
> composite of coluid and colkey (in that order) having 64,000 rows. Column
> coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio
> of
> 0.
> On SecondTable I have a clustered (non unique) primary key comprised of a
> composite of colfid and colkey (in that order) having 168,000 rows. Column
> colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio
> of
> 0.
> The two columns returned (st.col1, st.col2) from the select statement are
> not
> indexed.
> I was under the impression from various readings that having indexes on
> joins
> are beneficial, but in testing, when I have the clustered indexes, versus
> dropping the indexes and running the select statement, there is no
> difference
> in the output of statistics io.
> Also the execution plan states that each table receives a clustered index
> scan.
> The only benefit I see from having indexes on the joins is in CPU time,
> with
> indexes 187 ms., without 375 ms.
> Is that the benefit (reduced CPU, but no reduction of Logical Reads)
> spoken
> of when I read that indexes on joined columns are beneficial? Also,
> wouldn't
> my two columns returned be covered by the clustered index, if the index
> were
> ever used?
> --
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1|||I follow your logic in SQL Server 2000, of adding a clustered index on (st.
colfid, st.colkey, st.col1, st.col2). But I am not sure about your statement
regarding SQL 2005. Are you saying create a nonclustered index on (st.col1,
st.col2, st.colfid, st.colkey)? If so, what is the difference between the
indexing from SQL 2000 to SQL 2005 that would make you want to cluster in SQL
2000 and adding an additional nonclustered index in SQL 2005?
Tom Moreau wrote:
>Also. if you are using SQL Server 2000, try adding
>clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
>SQL 2005, create the nonclustered on (st.col1, st.col2) with included
>columns on (st.colfid, st.colkey).
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1|||I am receiving a merge join, with clustered index scans when the clustered
indexes are in use. Additionally I can change the clustered index scan for
the node representing FirstTable when I apply the filter "where ft.coluid >
0".
When the clustered indexes are removed I have table scans and a hash join.
Kalen Delaney wrote:
>A clustered index scan is a table scan, so that is no surprise.
>You cannot use statistics IO to tell which is the better plan. As you have
>noticed, the IO is the same, but the CPU is different. What kind of join
>does the plan say is being performed? Without indexes, my guess is that
>you're getting a hash join, which does a single pass through each table
>while it builds and analyzes hash lists. So the IO is only one pass through
>each table. But the extra work of building and examining the hash lists, but
>the extra memory required to stored the hashed information, can make that
>type of join very resource intensive.
>>I have the following select statement used to create a view:
>[quoted text clipped - 49 lines]
>> were
>> ever used?
--
Message posted via http://www.sqlmonster.com|||Sorry, I wasn't clear. I can change the clustered index scan for the node
representing FirstTable when I apply the filter "where ft.coluid 0" to a
clustered index seek.
cbrichards wrote:
>I am receiving a merge join, with clustered index scans when the clustered
>indexes are in use. Additionally I can change the clustered index scan for
>the node representing FirstTable when I apply the filter "where ft.coluid >
>0".
>When the clustered indexes are removed I have table scans and a hash join.
>>A clustered index scan is a table scan, so that is no surprise.
>>You cannot use statistics IO to tell which is the better plan. As you have
>[quoted text clipped - 11 lines]
>> were
>> ever used?
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1|||In SQL 2005, you have the option of "included columns". This makes covering
indexes more efficient, since the included columns exist only in the leaf
pages of the index. Basically, make the criteria from your JOIN and WHERE
clauses to be your index keys. Then make the included columns to be any
other columns from your SELECT list that don't already exist in your index
keys.
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"cbrichards via SQLMonster.com" <u3288@.uwe> wrote in message
news:60c845387d9c4@.uwe...
I follow your logic in SQL Server 2000, of adding a clustered index on (st.
colfid, st.colkey, st.col1, st.col2). But I am not sure about your
statement
regarding SQL 2005. Are you saying create a nonclustered index on (st.col1,
st.col2, st.colfid, st.colkey)? If so, what is the difference between the
indexing from SQL 2000 to SQL 2005 that would make you want to cluster in
SQL
2000 and adding an additional nonclustered index in SQL 2005?
Tom Moreau wrote:
>Also. if you are using SQL Server 2000, try adding
>clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
>SQL 2005, create the nonclustered on (st.col1, st.col2) with included
>columns on (st.colfid, st.colkey).
--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server/200605/1

Indexes on Joined Columns

I have the following select statement used to create a view:
select
st.col1,
st.col2
from
FirstTable ft
inner join
SecondTable st
on
ft.coluid = st.colfid
and
ft.colkey = st.colkey
My statistics are up to date.
On FirstTable I have a clustered (Unique) primary key comprised of a
composite of coluid and colkey (in that order) having 64,000 rows. Column
coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio of
0.
On SecondTable I have a clustered (non unique) primary key comprised of a
composite of colfid and colkey (in that order) having 168,000 rows. Column
colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio of
0.
The two columns returned (st.col1, st.col2) from the select statement are no
t
indexed.
I was under the impression from various readings that having indexes on join
s
are beneficial, but in testing, when I have the clustered indexes, versus
dropping the indexes and running the select statement, there is no differenc
e
in the output of statistics io.
Also the execution plan states that each table receives a clustered index
scan.
The only benefit I see from having indexes on the joins is in CPU time, with
indexes 187 ms., without 375 ms.
Is that the benefit (reduced CPU, but no reduction of Logical Reads) spoken
of when I read that indexes on joined columns are beneficial? Also, wouldn't
my two columns returned be covered by the clustered index, if the index were
ever used?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1Um, basically, you want the entire contents of both tables. How about
filtering in some way? Also. if you are using SQL Server 2000, try adding
clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
SQL 2005, create the nonclustered on (st.col1, st.col2) with included
columns on (st.colfid, st.colkey).
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"cbrichards via droptable.com" <u3288@.uwe> wrote in message
news:60c001bcd2645@.uwe...
I have the following select statement used to create a view:
select
st.col1,
st.col2
from
FirstTable ft
inner join
SecondTable st
on
ft.coluid = st.colfid
and
ft.colkey = st.colkey
My statistics are up to date.
On FirstTable I have a clustered (Unique) primary key comprised of a
composite of coluid and colkey (in that order) having 64,000 rows. Column
coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio of
0.
On SecondTable I have a clustered (non unique) primary key comprised of a
composite of colfid and colkey (in that order) having 168,000 rows. Column
colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio of
0.
The two columns returned (st.col1, st.col2) from the select statement are
not
indexed.
I was under the impression from various readings that having indexes on
joins
are beneficial, but in testing, when I have the clustered indexes, versus
dropping the indexes and running the select statement, there is no
difference
in the output of statistics io.
Also the execution plan states that each table receives a clustered index
scan.
The only benefit I see from having indexes on the joins is in CPU time, with
indexes 187 ms., without 375 ms.
Is that the benefit (reduced CPU, but no reduction of Logical Reads) spoken
of when I read that indexes on joined columns are beneficial? Also, wouldn't
my two columns returned be covered by the clustered index, if the index were
ever used?
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1|||A clustered index scan is a table scan, so that is no surprise.
You cannot use statistics IO to tell which is the better plan. As you have
noticed, the IO is the same, but the CPU is different. What kind of join
does the plan say is being performed? Without indexes, my guess is that
you're getting a hash join, which does a single pass through each table
while it builds and analyzes hash lists. So the IO is only one pass through
each table. But the extra work of building and examining the hash lists, but
the extra memory required to stored the hashed information, can make that
type of join very resource intensive.
HTH
Kalen Delaney, SQL Server MVP
"cbrichards via droptable.com" <u3288@.uwe> wrote in message
news:60c001bcd2645@.uwe...
>I have the following select statement used to create a view:
> select
> st.col1,
> st.col2
> from
> FirstTable ft
> inner join
> SecondTable st
> on
> ft.coluid = st.colfid
> and
> ft.colkey = st.colkey
> My statistics are up to date.
> On FirstTable I have a clustered (Unique) primary key comprised of a
> composite of coluid and colkey (in that order) having 64,000 rows. Column
> coluid has a selectivity ratio of 0.94 and colkey has a selectivity ratio
> of
> 0.
> On SecondTable I have a clustered (non unique) primary key comprised of a
> composite of colfid and colkey (in that order) having 168,000 rows. Column
> colfid has a selectivity ratio of 0.35 and colkey has a selectivity ratio
> of
> 0.
> The two columns returned (st.col1, st.col2) from the select statement are
> not
> indexed.
> I was under the impression from various readings that having indexes on
> joins
> are beneficial, but in testing, when I have the clustered indexes, versus
> dropping the indexes and running the select statement, there is no
> difference
> in the output of statistics io.
> Also the execution plan states that each table receives a clustered index
> scan.
> The only benefit I see from having indexes on the joins is in CPU time,
> with
> indexes 187 ms., without 375 ms.
> Is that the benefit (reduced CPU, but no reduction of Logical Reads)
> spoken
> of when I read that indexes on joined columns are beneficial? Also,
> wouldn't
> my two columns returned be covered by the clustered index, if the index
> were
> ever used?
> --
> Message posted via droptable.com
> http://www.droptable.com/Uwe/Forum...server/200605/1|||I follow your logic in SQL Server 2000, of adding a clustered index on (st.
colfid, st.colkey, st.col1, st.col2). But I am not sure about your statemen
t
regarding SQL 2005. Are you saying create a nonclustered index on (st.col1,
st.col2, st.colfid, st.colkey)? If so, what is the difference between the
indexing from SQL 2000 to SQL 2005 that would make you want to cluster in SQ
L
2000 and adding an additional nonclustered index in SQL 2005?
Tom Moreau wrote:
>Also. if you are using SQL Server 2000, try adding
>clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
>SQL 2005, create the nonclustered on (st.col1, st.col2) with included
>columns on (st.colfid, st.colkey).
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1|||I am receiving a merge join, with clustered index scans when the clustered
indexes are in use. Additionally I can change the clustered index scan for
the node representing FirstTable when I apply the filter "where ft.coluid >
0".
When the clustered indexes are removed I have table scans and a hash join.
Kalen Delaney wrote:[vbcol=seagreen]
>A clustered index scan is a table scan, so that is no surprise.
>You cannot use statistics IO to tell which is the better plan. As you have
>noticed, the IO is the same, but the CPU is different. What kind of join
>does the plan say is being performed? Without indexes, my guess is that
>you're getting a hash join, which does a single pass through each table
>while it builds and analyzes hash lists. So the IO is only one pass through
>each table. But the extra work of building and examining the hash lists, bu
t
>the extra memory required to stored the hashed information, can make that
>type of join very resource intensive.
>
>[quoted text clipped - 49 lines]
Message posted via http://www.droptable.com|||Sorry, I wasn't clear. I can change the clustered index scan for the node
representing FirstTable when I apply the filter "where ft.coluid 0" to a
clustered index seek.
cbrichards wrote:[vbcol=seagreen]
>I am receiving a merge join, with clustered index scans when the clustered
>indexes are in use. Additionally I can change the clustered index scan for
>the node representing FirstTable when I apply the filter "where ft.coluid >
>0".
>When the clustered indexes are removed I have table scans and a hash join.
>
>[quoted text clipped - 11 lines]
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1|||In SQL 2005, you have the option of "included columns". This makes covering
indexes more efficient, since the included columns exist only in the leaf
pages of the index. Basically, make the criteria from your JOIN and WHERE
clauses to be your index keys. Then make the included columns to be any
other columns from your SELECT list that don't already exist in your index
keys.
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
.
"cbrichards via droptable.com" <u3288@.uwe> wrote in message
news:60c845387d9c4@.uwe...
I follow your logic in SQL Server 2000, of adding a clustered index on (st.
colfid, st.colkey, st.col1, st.col2). But I am not sure about your
statement
regarding SQL 2005. Are you saying create a nonclustered index on (st.col1,
st.col2, st.colfid, st.colkey)? If so, what is the difference between the
indexing from SQL 2000 to SQL 2005 that would make you want to cluster in
SQL
2000 and adding an additional nonclustered index in SQL 2005?
Tom Moreau wrote:
>Also. if you are using SQL Server 2000, try adding
>clustered index on (st.colfid, st.colkey, st.col1, st.col2). If you have
>SQL 2005, create the nonclustered on (st.col1, st.col2) with included
>columns on (st.colfid, st.colkey).
Message posted via droptable.com
http://www.droptable.com/Uwe/Forum...server/200605/1

indexes are slowing down my query

sql2k sp3
Ive got a query that takes 30 seconds to run:
select top 50 customerkey as customerkey from transdtl
where MerchName in ('DTV*DIRECTV SERVICE','DTV*DIRECTV
SERVICER39')
and TranCode not in (7008,7023)
Group By CustomerKey
order by CustomerKey,min(TransDate)
Index Tuning Wizard wants to create an Composite Index on
MerchName, CustomerKey, TranCode, and TransDate. There is
already an Composite Index on TransDate, TranCode(in this
order) but for kicks I do the Wizards deal. Pretty cool in
that my query speeds up to only 1 second. Any yes, I
cleared the cache. Ive always followed the advice from
this article:
http://www.sql-server-performance.com/composite_indexes.asp
and for the most part used single column Indexes instead
of Composites. So, I drop the newly created Composite
Indexes, create 4 single coulmn Indexes, and expect it to
be about the same. Not only was it slower, but it was
slower now than when there was no Indexes on these
columns. 50 seconds. Ive tested this alot over the last
couple of days and its very consistant. Im getting a table
scan on the TranCode coulmn I noticed. I used an Index
Hint and have the same thing. Why is the Composite soooooo
much faster than the individuals? Why Is a Table Scan
occuring? Why is it slower than before? All ideas are
appreciated.
*** note: someone mentioned yesterday (thank you) that the
results are due to the ITW's index being a covered index.
That makes sense. But I am still not getting why my query
takes 20 seconds longer after adding individual indexes?
***
TIA, ChrisRHi,
Here is a bit of information I found in BOL:
"
Covered queries can improve performance. Covered queries
are queries where all the columns specified in the query
are contained within the same index. For example, a query
retrieving columns a and b from a table that has a
composite index created on columns a, b, and c is
considered covered. Creating indexes that cover a query
can improve performance because all the data for the query
is contained within the index itself; only the index
pages, not the data pages, of the table must be referenced
to retrieve the data, thereby reducing overall I/O.
Although adding columns to an index to cover queries can
improve performance, maintaining the extra columns in the
index incurs update and storage costs.
"
It seems that your individual indexes DO NOT cover your
query. Each time you run your query, the optimizer is
using 4 different index (one at a time) and it has
increased disk i/o. Increased disk i/o means slow query
response.
hth
DeeJay
>--Original Message--
>sql2k sp3
>Ive got a query that takes 30 seconds to run:
>
> select top 50 customerkey as customerkey from
transdtl
> where MerchName in ('DTV*DIRECTV
SERVICE','DTV*DIRECTV
>SERVICER39')
> and TranCode not in (7008,7023)
> Group By CustomerKey
> order by CustomerKey,min(TransDate)
>
>Index Tuning Wizard wants to create an Composite Index on
>MerchName, CustomerKey, TranCode, and TransDate. There is
>already an Composite Index on TransDate, TranCode(in this
>order) but for kicks I do the Wizards deal. Pretty cool
in
>that my query speeds up to only 1 second. Any yes, I
>cleared the cache. Ive always followed the advice from
>this article:
>http://www.sql-server-
performance.com/composite_indexes.asp
>and for the most part used single column Indexes instead
>of Composites. So, I drop the newly created Composite
>Indexes, create 4 single coulmn Indexes, and expect it to
>be about the same. Not only was it slower, but it was
>slower now than when there was no Indexes on these
>columns. 50 seconds. Ive tested this alot over the last
>couple of days and its very consistant. Im getting a
table
>scan on the TranCode coulmn I noticed. I used an Index
>Hint and have the same thing. Why is the Composite
soooooo
>much faster than the individuals? Why Is a Table Scan
>occuring? Why is it slower than before? All ideas are
>appreciated.
>*** note: someone mentioned yesterday (thank you) that
the
>results are due to the ITW's index being a covered index.
>That makes sense. But I am still not getting why my query
>takes 20 seconds longer after adding individual indexes?
>***
>TIA, ChrisR
>.
>|||>It seems that your individual indexes DO NOT cover your
>query. Each time you run your query, the optimizer is
>using 4 different index (one at a time) and it has
>increased disk i/o. Increased disk i/o means slow query
>response.
Has anyone else EVER encountered this before. I know I
never have. I built individual indexes on the same 4
columns that the ITW wanted to build a covered index on.
It slowed down my query by 40%. This is bizarre behavior.
I've only been a DBA for a few years, but I've NEVER had
this happen or even heard of it. Has anyone else? Is this
a bug?
>--Original Message--
>Hi,
>Here is a bit of information I found in BOL:
>"
>Covered queries can improve performance. Covered queries
>are queries where all the columns specified in the query
>are contained within the same index. For example, a query
>retrieving columns a and b from a table that has a
>composite index created on columns a, b, and c is
>considered covered. Creating indexes that cover a query
>can improve performance because all the data for the
query
>is contained within the index itself; only the index
>pages, not the data pages, of the table must be
referenced
>to retrieve the data, thereby reducing overall I/O.
>Although adding columns to an index to cover queries can
>improve performance, maintaining the extra columns in the
>index incurs update and storage costs.
>"
>It seems that your individual indexes DO NOT cover your
>query. Each time you run your query, the optimizer is
>using 4 different index (one at a time) and it has
>increased disk i/o. Increased disk i/o means slow query
>response.
>hth
>DeeJay
>>--Original Message--
>>sql2k sp3
>>Ive got a query that takes 30 seconds to run:
>>
>> select top 50 customerkey as customerkey from
>transdtl
>> where MerchName in ('DTV*DIRECTV
>SERVICE','DTV*DIRECTV
>>SERVICER39')
>> and TranCode not in (7008,7023)
>> Group By CustomerKey
>> order by CustomerKey,min(TransDate)
>>
>>Index Tuning Wizard wants to create an Composite Index
on
>>MerchName, CustomerKey, TranCode, and TransDate. There
is
>>already an Composite Index on TransDate, TranCode(in
this
>>order) but for kicks I do the Wizards deal. Pretty cool
>in
>>that my query speeds up to only 1 second. Any yes, I
>>cleared the cache. Ive always followed the advice from
>>this article:
>>http://www.sql-server-
>performance.com/composite_indexes.asp
>>and for the most part used single column Indexes instead
>>of Composites. So, I drop the newly created Composite
>>Indexes, create 4 single coulmn Indexes, and expect it
to
>>be about the same. Not only was it slower, but it was
>>slower now than when there was no Indexes on these
>>columns. 50 seconds. Ive tested this alot over the last
>>couple of days and its very consistant. Im getting a
>table
>>scan on the TranCode coulmn I noticed. I used an Index
>>Hint and have the same thing. Why is the Composite
>soooooo
>>much faster than the individuals? Why Is a Table Scan
>>occuring? Why is it slower than before? All ideas are
>>appreciated.
>>*** note: someone mentioned yesterday (thank you) that
>the
>>results are due to the ITW's index being a covered
index.
>>That makes sense. But I am still not getting why my
query
>>takes 20 seconds longer after adding individual indexes?
>>***
>>TIA, ChrisR
>>.
>.
>|||On Thu, 24 Jun 2004 08:39:28 -0700, ChrisR wrote:
>This is bizarre behavior.
Hi Chris,
No, it is not. Both Greg and DeeJay already pointed out that one index on
all columns required for the query means that SQL Server has to access
this index only. Individual indexes are not covering; SQL Server might
choose to read all indexes and merge the results, or use one index and
fetch the data pages through that index. In both cases, more disk access
is required than when one covering index on all columns can be used.
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)

indexes are slowing down my query

sql2k sp3
Ive got a query that takes 30 seconds to run:
select top 50 customerkey as customerkey from transdtl
where MerchName in ('DTV*DIRECTV SERVICE','DTV*DIRECTV
SERVICER39')
and TranCode not in (7008,7023)
Group By CustomerKey
order by CustomerKey,min(TransDate)
Index Tuning Wizard wants to create an Composite Index on
MerchName, CustomerKey, TranCode, and TransDate. There is
already an Composite Index on TransDate, TranCode(in this
order) but for kicks I do the Wizards deal. Pretty cool in
that my query speeds up to only 1 second. Any yes, I
cleared the cache. Ive always followed the advice from
this article:
http://www.sql-server-performance.com/composite_indexes.asp
and for the most part used single column Indexes instead
of Composites. So, I drop the newly created Composite
Indexes, create 4 single coulmn Indexes, and expect it to
be about the same. Not only was it slower, but it was
slower now than when there was no Indexes on these
columns. 50 seconds. Ive tested this alot over the last
couple of days and its very consistant. Im getting a table
scan on the TranCode coulmn I noticed. I used an Index
Hint and have the same thing. Why is the Composite soooooo
much faster than the individuals? Why Is a Table Scan
occuring? Why is it slower than before? All ideas are
appreciated.
TIA, ChrisRcomposite is a covering index so all the data SQL needs is actually IN The
index.
Once SQL reads the index, it HAS the data (Literally)
in piece meal indexes, once the index is read, a table lookup must be
performed. You likely see this in your Query Plan as Bookmark lookups.
basically, way more IO required with the piece meal indexes.
Greg Jackson
PDX, Oregon|||So then why is the query slower than when I started?
"Jaxon" <GregoryAJackson@.hotmail.com> wrote in message
news:uUC6enXWEHA.3740@.TK2MSFTNGP12.phx.gbl...
> composite is a covering index so all the data SQL needs is actually IN The
> index.
> Once SQL reads the index, it HAS the data (Literally)
> in piece meal indexes, once the index is read, a table lookup must be
> performed. You likely see this in your Query Plan as Bookmark lookups.
> basically, way more IO required with the piece meal indexes.
> Greg Jackson
> PDX, Oregon
>|||really hard to say without looking at perfmon data, profiler results, yadda
yadda yadda.
However, I would point to the usual suspects...
1. Could be your indexes are becoming fragmented (Run dbcc showcontig to
find out if scan density has dropped below 80% on any of the indexes\tables
in question)
2. statistics out of date
3. Data has changed - you have more data than before perhaps
4. other schema changes impacting the query now that werent impacting it
before
5. some blocking is occuring that was not occuring before
I dunno.
GAJ