473,503 Members | 8,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compound vs Simple Indexes

I have two tables. I want to get one column from table B into table
A. I have added a "blank" column in table A for that information.

The "link" criteria is on 3 columns. What I am wondering is if I am
better off creating 3 different indexes (one for each column) or a
single index of all 3 columns.

Thanks,

S
Jun 27 '08 #1
2 5457
It is always best to test with your data, table structures, and compare
execution plans. In general since a composite index is wider it may be
slower for maintenance and require more I/O. Also, statistics are kept only
on the first column of the index and it is really important how selective
the first column is. A single column index will fit more keys on an index
page, potentially providing faster seek.

HTH,

Plamen Ratchev
http://www.SQLStudio.com

Jun 27 '08 #2
(sc******@gmail.com) writes:
I have two tables. I want to get one column from table B into table
A. I have added a "blank" column in table A for that information.

The "link" criteria is on 3 columns. What I am wondering is if I am
better off creating 3 different indexes (one for each column) or a
single index of all 3 columns.
We have far too little information to say anything with certainty.
But generally, if you have something like:

SELECT ...
FROM tbl
WHERE col1 = @val1
AND col2 = @var2
AND col3 = @var3

A compound index on (col1, col2, col3) is more efficient than three single
index, as SQL Server then can locate all matching rows directly. If there
are three single index, SQL Server may only use the index which it thinks
is the most selective, and then do lookups to filter on the other two
columns.

But depending on how your query and tables look like, not even a compound
index may be used.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2470
by: Benjamin Scott | last post by:
Hello. I attempted to build a compound dictionary: len(Lst)=1000 len(nuerLst)=250 len(nuestLst)=500 Dict={}
1
2908
by: robert | last post by:
i can't find a thread which answers the question: does oracle (8.1.x) benefit from having multiple compound keys? NonUniqueKey -> col1 + col2 + col3 OtherNonUniqueKey -> col1 + col2 a where...
4
4423
by: Sonia | last post by:
I have been looking for a definition of a compound class but cannot find it anywhere ? What exactly is a compound class ? Thanks
3
1552
by: andrewbb | last post by:
Is it possible to force the use of a compound index in a query? create table Test (ColOne int, ColTwo int) The compound index is ColOne + ColTwo. I'm interested in searching on ColTwo, but I...
6
3730
by: David W. Fenton | last post by:
I'm generally against using compound keys, except in join tables, but I'm currently mapping out a schema where the join table has child records. The application is for fund-raising and I have four...
7
1915
by: Eric Laberge | last post by:
Aloha! This question is meant to be about C99 and unnamed compound objects. As I read, if such a construct as int *p = (int){0}; is used within a function, then it has "automatic storage...
8
3511
by: wespvp | last post by:
I am using PostgreSQL 7.4.1 on RedHat 7.2. The query I am executing is something like (I replaced all the return values with 'count'): db=> explain select count(*) from messages m join (select...
7
5432
by: Timo Haberkern | last post by:
Hi there, i have some troubles with my TSearch2 Installation. I have done this installation as described in http://www.sai.msu.su/~megera/oddmuse/index.cgi/Tsearch_V2_compound_words...
6
8376
by: c_beginner | last post by:
yes, this is my how work question. Since I am lack in getting an assistance with my lab work I put this in this advance group. Sorry for the trouble I am making. Write a program to calculate the...
0
7070
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6976
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5566
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4993
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4666
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
372
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.