Multiple Indexes

Apr 15, 2008

I have a stored procedure that we use to search our inventory.

The sproc is using dynamic sql and executing a parameterized.

It generates the sql string based on all the parameters passed in.

I'm trying to figure out how I should set up the indexes on the table(s) being queried.

There are 12 different fields possible in the where clause and 7 different order by's.

I heard that SQL 2005 might hash together multiple indexes so should I create an index for each of these fields?

View 7 Replies


ADVERTISEMENT

Indexes In Multiple Databases

Nov 1, 2000

Okay this is a test...actually I am still learning SQL and need some help. Does anyone have any information on being able to move indexes from one database to another. My scenario is I have 3 databases, Development, QA and Production. I want to move/copy indexes I created in Development to the QA database. I have many indexes so I do not want to have to recreated them if I can avoid it. Any suggestions?

Thanks!

View 1 Replies View Related

Multiple Indexes On The Same Column

Jan 21, 2008

Hi All

I have a table with indexes as follows









license_detail_prim
clustered, unique located on PRIMARY
component_id, license_id

LICENSE_DTL_IDX_LICENSE_ID
nonclustered located on PRIMARY
license_id

PK__license_dtl__6EB64F9B
nonclustered, unique, primary key located on PRIMARY
component_id, license_id

XIF39license_dtl
nonclustered located on PRIMARY
license_id


from the above, it is evident that multiple indexes have been created on the same columns

What is the side effects of havins such table design.

Thanks

View 5 Replies View Related

Problem With Where Clause When Multiple DESC Indexes

May 12, 2007

I have come across a problem executing a select with a multi-part where clause that only shows up if there are multiple indexes on the table. The situation using a simplified table is shown below

create table tblTest( utcTimestamp datetime NOT NULL, testType int NOT NULL)go

insert into tblTest (utcTimestamp, testType) VALUES('6/1/2003 0:0:0', 100)go

Now, without adding any indexes to the table, I can execute the following select and it works fine, returning the single row in 2003:

select * from tblTest where utcTimestamp < '1/1/2004 0:0:0' and utcTimestamp > '1/1/2003 0:0:0' and testType = 100go

Furthermore, if I introduce a single descending index on just the utcTimestamp:

CREATE INDEX IX_tblTest_Timestamp ON tblTest (utcTimestamp DESC)go

the search still works.

HOWEVER, if I now introduce another index:

CREATE INDEX IX_tblTest_EntryType_Timestamp ON tblTest ( testType, utcTimestamp DESC)go

the search does **not** return the row.
However, if I change the where clause to remove the test of testType:

select * from tblTest where utcTimestamp < '1/1/2004 0:0:0' and utcTimestamp > '1/1/2003 0:0:0'go

it works.

Also, strangely, if I populate the table with a number of records with different dates and execute the following search:

select * from tblTest where utcTimestamp > '1/1/2004 0:0:0' and testType = 100go

I get records from **earlier** than 1/1/2004 (i.e. like the sense of the compare is wrong)

Finally, as I was writing this report, I discovered that all of these problems go away if the DESC is removed from the indexes - so that's my workaround, but it still looks like a bug.

Thanks
Lionel

View 1 Replies View Related

Multiple Columns Index/Key (does It Free Me From Creating A Single Column Indexes???)

Apr 12, 2007

I hope i'm in the right place, but thanks anyway....

Actually i have 2 questions (regarding sql-server Indices/Keys):



1) I have an index, which is consisted of 4 columns.

I've read elsewhere that this index functions (as well) as an index (single column

index) on the first column of this multi-column index.



Does this mean that if i'd like to have (in addition) Indices on all of the 4 columns

seperately i need to define only 3???



2) I have a unique key consisted of multiple columns.

I'd like to save an index to this combination of columns as well (to speed up

things in DB...).

Does the definition of a multiple-columns key free me from defining the multiple-

columns index???

can anyone explain the main diference between Keys and Indices???





View 1 Replies View Related

Multiple Columns Index/Key (does It Free Me From Creating A Single Column Indexes???)

Apr 16, 2007

I hope i'm in the right place, but thanks anyway....

Actually i have 2 questions (regarding sql-server Indices/Keys):



1) I have an index, which is consisted of 4 columns.

I've read elsewhere that this index functions (as well) as an index (single column

index) on the first column of this multi-column index.



Does this mean that if i'd like to have (in addition) Indices on all of the 4 columns

seperately i need to define only 3???



2) I have a unique key consisted of multiple columns.

I'd like to save an index to this combination of columns as well (to speed up

things in DB...).

Does the definition of a multiple-columns key free me from defining the multiple-

columns index???

can anyone explain the main diference between Keys and Indices???


thanks,

Ran Kizi

View 3 Replies View Related

Integration Services :: SSIS Cache Transform Lookup With Multiple Indexes

Jan 16, 2013

I work in the healthcare area, and am handling the survey data ETL's.  There are around 8 different survey areas and based on information received from them for the visit they reference, I want to pull in more info from our invoicing database.  My idea is this:

1.)  Pull in the flat file to an ODBC staging table
2.)  Cache all invoice records that fall between the MIN(Date of Service) and MAX(Date of Service) from the staging table.
3.)  First lookup the information needed on patientID, providerID, date of service, and billing location.
4.)  For the surveys that didn't match on those 4 columns, try looking up based on patientID, date of service, and billing location (since I could be 99% sure this would still return the record I need).
5.)  For the remaining surveys, lookup based just on patientID and date of service.  These records will be flagged for manual review because clearly, if a patient has multiple appointments in the same day, this will be prone to error.

However, in trying to use only 3 of the columns in the lookup, I get the error saying basically that I need to utilize all 4. Is there a way around this, or is there an entirely different way I should be approaching this?  The reason I thought cache transform was the answer is because I will need to run a different package for each lookup, as the data and logic between each survey will vary, but the invoice data "pool" will stay the same regardless. 

View 5 Replies View Related

Removal Of Selected Indexes / Script Index Create For List Of Indexes

Jul 1, 2014

I'm working to improve performance on a database I've inherited, and there are several thousand indexes. I've got a list of ones which should definitely exist within the database, and I'm looking to strip out all the others and start fresh, though this list is still quite large (1000 or so).

Is there a way I can remove all the indexes that are not in my list without too much trouble? I.e. without having to manually go through them all individually. The list is currently in a csv file.

I'm looking to either automate the removal of indexes not in the list, or possibly to generate the Create statements for the indexes on the list and simply remove all indexes and then run these statements.

As an aside, when trying to list all indexes in the database, I've found various scripts to do this, but found they all seem to produce differing results. What is the best script to list all indexes?

View 5 Replies View Related

A Question About Clustered Indexes Forcing Rebuild Of Non-clustered Indexes.

Sep 18, 2007

So I'm reading http://www.sql-server-performance.com/tips/clustered_indexes_p2.aspx and I come across this:
When selecting a column to base your clustered index on, try to avoid columns that are frequently updated. Every time that a column used for a clustered index is modified, all of the non-clustered indexes must also be updated, creating additional overhead. [6.5, 7.0, 2000, 2005] Updated 3-5-2004
Does this mean if I have say a table called Item with a clustered index on a column in it called itemaddeddate, and several non-clustered indexes associated with that table, that if a record gets modified and it's itemaddeddate value changes, that ALL my indexes on that table will get rebuilt? Or is it referring to the table structure changing?
If so does this "pseudocode" example also cause this to occur:
sqlstring="select * from item where itemid=12345"
rs.open sqlstring, etc, etc, etc
rs.Fields("ItemName")="My New Item Name"
rs.Fields("ItemPrice")=1.00
rs.Update
Note I didn't explicitly change the value of rs.fields("ItemAddedDate")...does rs.Fields("ItemAddedDate")=rs.Fields("ItemAddedDate") occur implicitly, which would force the rebuild of all the non-clustered indexes?

View 4 Replies View Related

SQL Server 2008 :: Logic To Rebuild Only Clustered Indexes / Skipping To Rebuild Non Clustered Indexes In Same Table

Jun 25, 2015

I have a requirement to only rebuild the Clustered Indexes in the table ignoring the non clustered indexes as those are taken care of by the Clustered indexes.

In order to do that, I have taken the records based on the fragmentation %.

But unable to come up with a logic to only consider rebuilding the clustered indexes in the table.

create table #fragmentation
(
FragIndexId BigInt Identity(1,1),
--IDENTITY(int, 1, 1) AS FragIndexId,
DBNAME nvarchar(4000),
TableName nvarchar(4000),

[Code] ....

View 5 Replies View Related

Indexes Vs Clustered Indexes

Sep 17, 2006

What is the difference please?

View 1 Replies View Related

Indexes

Jul 31, 2002

Sir,

1. How do I call the indexes created in SQL server for a table from Front end VB programming ?
2. How can I use SEEK command with ADODB control ?

Please give me some tips & samples

Sundar Raman

View 1 Replies View Related

Indexes

Jul 23, 2001

Does anyone have the idea why the Indexes with _WA.....(like _WA_Sys_au_fname_07020F21) gets created.I don't how this index got created. I did not create this Index.
My Question is does the system creates these indexes or something else does this.
Thanks
Chak

View 1 Replies View Related

DB Indexes

Jul 27, 2000

Is there a way to tell how many indexes exist for an entire database, all I'm looking is for a count or generating a report list.
any help would be appreciated, thank you

View 2 Replies View Related

Indexes

Sep 13, 2000

At present I have been assigned to create indexes to retrieve the information fast, from the table. The existing table doesn’t have primary key, foreign key and unique constraints but I found to many default indexes already created by the system. I would like to know how this happened? Please inform how to delete these default indexes. Further, inform me other possible ways for the faster retrieval in SQL sever 7.0, if there are any.

I would appreciate if you send me a step by step explanations for the above problems.

Thanks a lot

View 1 Replies View Related

Indexes Not Being Used

Nov 20, 2000

I have run into a snag on my development server. Queries that are selecting data based on indexed fields in a where clause are using the wrong indexes. They are arbitrarily using the clustered index which isn't in the select at all and causing big performance problems. I can run the same statements on my production server and it runs based on the proper indexes. I used query execution plans to determine that this was infact the case.

I run DBCC Checkdb everynight and it comes back with no errors. I also rebuild the indexes. We also don't receive any other errors inputting or updating data. This sounds like corruption to me but if it's something else I don't want to spend the night restoring from production if there is another reason.

Has anyone encountered this before? Any ideas?

Appreciate it, K.

View 1 Replies View Related

6.5 Indexes

Jan 10, 2001

Is there any way for me to find out when last indexes have been used so that the one I don't need can be dropped.And also the one's that are of no use at all.
I need this as i am trying to dump all duplicated indexe . i know i can do this in ver 7

thanks

View 2 Replies View Related

Indexes

Feb 5, 2000

when executed sp_help tablename, I get lot of statistics and indexes like the following. Can anyone please tell me how it is generated automatically. as far i know statistics are generated only for primary keys. Can you please tell me what is clustered , hypothetical and the indexes starting with _WA supposed to be. Also there are lot of duplicate stats. Is it Ok to deletes those.
_WA_Sys_is_platinum_0A9D95DB
_WA_Sys_active_0A9D95DB nonclustered, statistics, auto create located on PRIMARY Active
hind_c_33_15 nonclustered, statistics located on
hind_c_37_1 clustered, hypothetical located


Thanks
Raj

View 2 Replies View Related

Indexes

Mar 2, 2001

Is there a way T-SQL script can find out all indexes built on a set of tables, drop them and periodically ( quarterly as an example ) re-build them ?

Thanks in advance for help.

Ivan

View 1 Replies View Related

Indexes

Mar 5, 2001

How do you find out indexes ( with column names info ) on a table ?

Thanks in advance.
Ivan

View 3 Replies View Related

Indexes!

Jun 20, 2001

I am on SQL 6.5.

I have a question about speed and indexes. I have a static table (no updates except once a year). I want to be able to search data quickly on one column or many columns. I have created nonclustered indexes on each of the columns I search by. Is there anything else I can do to speed up my queries? Unfortunately all the searches involve using the like operator. I have even broken my table down into 2 smaller tables (Table A ~ 3 million rows, Table B 8 million rows).

All suggestions will be appreciated.

Thanks,

Eric

View 2 Replies View Related

The Indexes

Nov 12, 1998

We have to interduce a new naming convention for the indexes currently available in the user databases.

We also have to drop all the old indexes available in about 250 tables and recreate them all acording to the naming convention we are coming up with.

Can any body suggest any idea.

I thank you guys in advance for your considaration.

View 2 Replies View Related

Indexes

Mar 10, 2006

hi.

there 2 different queries

1
[MYSQL].... where Cat=@CatID and Date=@Date[/MYSQL]


2
[MYSQL]... where Cat=@CatID and Date=@Date and Salesman=@SID[/MYSQL]

these queries are often used.
my question is about indexes.

should I use two different indexes?

index 1 : Cat,Date
index 2 : Cat,Date,Salesman

or only index 2 is enough ?

View 8 Replies View Related

SQL Indexes

Jul 11, 2006

I need to alphabetize PART of a union all query, and was told that this may be accomplished with an index. I tried joining two views, but it does not work! I have NO experience with indexes and need some help.

Here is my code:

Select id, country from countries where id = 6 union all Select id, country from countries where id <> 6

I want the country with id 6 (USA) to be the default on a drop down list, then all the other countries listed after it in alphabetical order. Can you do this with an index? If so, how do I proceed?

Thanks!

Ronna

View 6 Replies View Related

All Indexes In DB

Nov 15, 2004

Hi all,

I want to know all indexes in database.
What do I do to get them?

Thanks in advanced,
Thi Nguyen

View 4 Replies View Related

Indexes

Feb 6, 2006

We recently updated some of the databases from MS Access 2000 to SQL Server 2000. In Access we had columns which were set to Indexed No Duplicates, these were not Primary key fields. Is this possible to set some indexes to prevent duplicates in SQL Server without creating performance issues?

Miranda

View 2 Replies View Related

Indexes

Feb 16, 2006

Do you have to take the DB offline to create or run indexes in SQL Server 2000??

View 2 Replies View Related

Indexes

May 30, 2007

Q1
The table i have stores max 2000 records. Not sure if i neeed a clustered index for this few records. I guess not.


Q2
For the same table as above. How do you create primary keys if there is not unique records.
Do i create a new column? like newColumnID identity? and create a primary key on this new column? Ok even if i create this newcolumn. I don't think it will improve the retrieving speed cause i'm not selecting this column.

Opinions, ideas?

View 2 Replies View Related

Indexes

Aug 24, 2007

i am running a stored procedure which has got clustered indexes created after creating table and data is inserted into it after creating clustered indexes. The tables which are meant in this sp is temporary tables and how to gain the performance of a query

View 2 Replies View Related

Indexes

Nov 16, 2007

I've created indexes for the queries below running select getdate() before and after the query to determine the time. I'm curioius as to how sql server determines and decides how and when to use the indexes for the queries and how the run times of these queries compare. I'm also curious to know what kind of difference there would be on the last two queries as the only difference is the values.
For the last two queries I don't think there would be a difference but hoping that someone would know.

Below are my results:

select count(distinct CustomerID)
from Orders
where Status = 5

SELECT getdate()
go
Create Index Orders_Index On Orders(customerID)
go
SELECT getdate()


select sum(TotalDue)
from Orders
where CustomerID = 11212

select getdate()
go
Create Index Orders_Index On Orders(customerID)
go
select getdate()


select count(distinct AccountNumber)
from Orders
where SalesPersonID = 288

select getdate()
go
Create Index Orders_Index On Orders(salespersonID)
go
select getdate()


select count(distinct AccountNumber)
from Orders
where SalesPersonID = 276

select getdate()
go
Create Index Orders_Index On Orders(salespersonID)
go
select getdate()

View 16 Replies View Related

Indexes

Sep 13, 2007

where can i find a example on how tobuild a script to reindex all my tablesTksDaveP

View 2 Replies View Related

Should I Use Indexes?

Aug 31, 2006

I have a very large table (about 200,000 records), but there are only 2 fields in the table only one populated with data. I need to update the 2nd field with the first field's data.

UPDATE Table1
SET field2 = field1

This is taking a really long time to run about 3.5 minutes.
Is this normal? Can I create an index? What can I do to shorten the run time?

Thanks,
Ninel

View 9 Replies View Related

Indexes

Apr 23, 2008

Aren't all indexes created as separate structures from a table?
Although the index is created against a particular
table, doesn't the index itself exist in the database as a separate,
self-contained structure?


Which index type -- clustered or nonclustered -- logically
sorts the database of a table?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved