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 8494147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:13:12+00:00 2026-06-10T23:13:12+00:00

I am using a composite primary key consisting of 2 strings Name1, Name2, and

  • 0

I am using a composite primary key consisting of 2 strings Name1, Name2, and a timestamp (e.g. ‘Joe:Smith:123456’). I want to query a range of timestamps given an equality condition for either Name1 or Name2.

For example, in SQL:

SELECT * FROM testcf WHERE (timestamp > 111111 AND timestamp < 222222 and Name2 = 'Brown');

and

SELECT * FROM testcf WHERE (timestamp > 111111 AND timestamp < 222222 and Name1 = 'Charlie);

From my understanding, the first part of the composite key is the partition key, so the second query is possible, but the first query would require some kind of index on Name2.

Is it possible to create a separate index on a component of the composite key? Or am I misunderstanding something here?

  • 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-10T23:13:14+00:00Added an answer on June 10, 2026 at 11:13 pm

    You will need to manually create and maintain an index of names if you want to use your schema and support the first query. Given this requirement, I question your choice in data model. Your model should be designed with your read pattern in mind. I presume you are also storing some column values as well that you want to query by timestamp. If so, perhaps the following model would serve you better:

    "[current_day]:Joe:Smith" {
        123456:Field1 : value
        123456:Field2 : value
        123450:Field1 : value
        123450:Field2 : value
    }
    

    With this model you can use the current day (or some known day) as a sentinel value, then filter on first and last names. You can also get a range of columns by timestamp using the composite column names.

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

Sidebar

Related Questions

I have a table called table1 which has a composite primary key using 'ScreenId'
I'm using NUnit v2.5 to compare strings that contain composite Unicode characters. Although comparison
How to set a composite primary key for a All in One approach (grid
How to identify composite primary key in any Mysql Database table? or EDIT 2
I need to use Fluent-nHibernate against a table with a composite primary key (Azure
I get this error when using linq-to-sql with timestamp as part of a composite
I have table structures that include a composite primary key of id & revision
I'm trying to add a composite primary key to a class and having a
I have a JPA Entity StatsEntity which has a composite primary key that is
I have two fields being used as composite primary key which are not auto

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.