473,545 Members | 1,989 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 5461
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****@sommarsk og.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
2473
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
2912
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 clause -> where col1 = 'A' and col2 = 'B' other databases i've used would retrieve (based on the
4
4429
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
1559
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 also know the value of ColOne will always be the number "1". How do you structure the SQL statement to concatenate the two INTs and
6
3734
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 relevant tables: tblPerson tblOutreach -- the list of fund-raising actions/events (letters, events, etc.) To join these two tables, I have:
7
1923
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 duration associated with the enclosing block". So I tried the annexed code, and it compiles without a warning, and works as I expected.
8
3515
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 * from message_recipients r join addresses a on a.Address_Key=r.Recipient where a.Address='lra.edi@edi.cma-cgm.com') as foo on...
7
5438
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 <http://www.sai.msu.su/%7Emegera/oddmuse/index.cgi/Tsearch_V2_compound_words> I used the german myspell dictionary from...
6
8389
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 compound interest. #include<stdio.h> #include<stdlib.h> double intrest(double tot_amount,float percent) {
0
7487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4966
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3476
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1908
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 we have to send another system

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.