473,399 Members | 3,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Clustered Index example of exception to the rule

Per my research the ideal clustered index should be a narrow column and unique. We are currently on SQL Server 2012 and have a database setup for merge replication. I am in the process of adding a new table, StoreOPenDocuments, to our database. I am unsure what the clustered index should be.

Table StoreOpenDocuments
StoreOpenDocumentsID defined as UniqueIdentifier
CustomerID defined as UniqueIdentifier
InvoiceNumber
GrossAmount
.

Table MemberShipList (existing table)
CustomerID defined as UniqueIdentifier
StoreName
StoreAddressLine1
.

Would it make sense to make the StoreOpendocuments.CustomerID the clustered index even though it is not unique and is done on a UniqueIdentifier column?
Majority of our select statements will have where CustomerID = XXX
Or should I have the StoreOpenDocumetnsID be the clustered index, at least it is unique.

Thank you in advance for your time,
Tsharp89
Apr 8 '16 #1
1 1592
Rabbit
12,516 Expert Mod 8TB
Clustered indexes are typically used to store rows in a table in a certain order to reduce the cost of a sort in a query. For the most part, it looks like you're just filtering or joining on the customer id so there's no need for a clustered index. Just create a regular index on it.
Apr 11 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jim | last post by:
I put a clustered index on a table with 2 columns -nationalityid int autoincrement PK -nationality varchar(50) the clustered index is on nationality however; when i do a select i still...
4
by: Tryfon Gavriel | last post by:
Hi all I recently noticed when trying to optimise a major query of a chess website I am the webmaster of, that adding an order by for "gamenumber" which is a clustered index field as in for...
2
by: Miss Livvy | last post by:
Would it be OK to use varchar(5) instead of char(5) as the first field of a composite clustered index? My gut tells me that varchar would be a bad idea, but I am not finding much information on...
5
by: jim_geissman | last post by:
One table I manage has a clustered index, and it includes some varchar columns. When it is initially created, all the columns in the clustered index are populated, and then some of the longer...
6
by: bala | last post by:
hi guru's would appreciate if someone could show how to list all the clustered indexes in the database. if it can done as a output of single query it would be fine. the output should be the...
5
by: Dimitri Furman | last post by:
This looks like a bug - hopefully somebody can explain what is actually happening. Using SQL Server 2000 SP4. Here's a repro script with comments: /* repro table */ CREATE TABLE dbo.T ( ID...
1
by: anonieko | last post by:
A lot of detailed discussion explains the difference between clustered and non-clustered indexes. But very few 'clarifies' why the term used is 'clustered'. Well, once and for all, this is my...
2
by: ppuniversal | last post by:
Hi, I have a table in SQL Server 2000 with clustered index set on the Primary key. The primary key is a set of 5 fields(attributes). Now I want to add 1 more field into this clustered index as...
4
by: codefragment | last post by:
Hi I thought that given a table with an index, primary key and clustered index any non clustered index look ups would go via the clustered index and the primary key is irrelevant? (sql server...
0
by: Tawfiq | last post by:
Hi, I have got the following situation please give me some ideas how to solve/work around it. Current situation: Everyday day about 10 million records are processed and bulk inserted in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.