Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8760195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:59:02+00:00 2026-06-13T14:59:02+00:00

Is it redundant to add a separate, single-column index on the first field of

  • 0

Is it redundant to add a separate, single-column index on the first field of a multicolumn primary key? Does it depend on the relative quantitiy of unique values in that first column compared to the size of the table?

My specific scenario is that I’m building several moderately sized tables (20k – 500k rows) with two- and three-column primary keys. The first column in these tables is an integer which corresponds to a certain business activity (I’ll just call it an “activity” here) and the second column is either a product ID (a UPC actually) or a business location identifier:

-- Activity - upc table: entire table is a two-column primary key
CREATE TABLE activity_upc (
    activity_id int NOT NULL,
    upc_id dec(18,0) NOT NULL,
    CONSTRAINT PRIMARY KEY PK_activity_upc CLUSTERED ( activity_id, upc_id )
) 

-- One of several transaction tables, unique by activity, location, and date
-- (date in SQL server is a 3-byte integer)
CREATE TABLE activity_stuff (
    activity_id int NOT NULL,
    location_id smallint NOT NULL,
    transaction_date date NOT NULL,
    [ other columns ],
    CONSTRAINT PRIMARY KEY PK_activity_stuff CLUSTERED ( 
        activity_id, location_id, transaction_date )
)

There are several hundred unique locaton IDs, several thousand unique activity IDs, and over a million unique UPCs. I have an index on the location_id because it is very frequent to query just by location_id. Would it help, or be silly and redundant, to add a separate index on activity_id, which is also used frequently as a single-column filter?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:59:03+00:00Added an answer on June 13, 2026 at 2:59 pm

    It is redundant. You can easily check it by adding/deleting index and comparing explain results. On the other hand, for the second column in your composite key additional index will help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following steps result in a crash in NSFetchedResultsController. I try to add the first
Does this rankle anyone else out there? I would much rather see: block.key(newKey); //
I have one table called users with a PRIMARY key on users.zbid . However,
Is it redundant to run git add . and then git commit -am commit
This seems redundant, running perl from a Perl script itself. my $Pref = &*())(*&^%$#@!;
I think the option command is redundant because it can be replaced by the
I want to drop a now supposedly redundant file in SQL Server (2005), but
EDIT: This question is now redundant since Twitter no longer supports basic auth. I've
The getCategory method below seems very redundant and I was wondering if anyone has
I'm not sure if the following code can cause redundant calculations, or is it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.