download Sanam Re movies 720p torrentQ:
Should I use two different types of indexes for an SQL server DB?
I have a table with a FK relationship to another table. This table is typically queried for several columns but has a large amount of data and the majority of the data is not used. My goal is to improve the performance of my queries by adding indexes to the columns I most frequently use in queries. I'm wondering if adding an index to a column that doesn't frequently get queried will affect the performance of queries that use that column.
I was wondering what others have done in a similar situation.
A:
No, it shouldn't matter.
I would definitely add your "frequently queried" columns, because they will speed up your queries and possibly even lead to execution plans that use them for filtering the data rather than joining (e.g. the optimizer chooses a better execution plan because it knows the columns can be efficiently used).
But in the example you gave, the column that's not frequently used is used to define a relationship between the two tables, so you're not going to get any value out of adding an index on it.
There are two main points to remember about index usage:
Indexes are usually added to a table to ensure a good query execution plan (and good performance), so don't waste your time or your DBMS's time by adding indexes that don't result in any benefit to your queries.
Indexes shouldn't add any measurable overhead to your queries, so don't spend your time (and your DBMS's time) on the process of adding indexes that won't provide any benefit.
A:
The index shouldn't affect the queries.
You can look at an online scenario where the same query is being executed on Oracle and SQL Server. I think, for the most part, Oracle does a good job at optimizing the query on their own.
The other thing to watch is how your queries are being written.
A good example of this would be if you had a lookup table, which was indexed on the primary key. In that case, you could add a second index, indexed by a column that contains the foreign key.
The following query, when run on Oracle would use the primary key as the starting point and use the index to perform a nested loop join:
select col1, col2,
from table1 t1 be359ba680
Related links:
Comments