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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:31:01+00:00 2026-06-06T12:31:01+00:00

Ok I know the basics about when indexing should be used and the pros

  • 0

Ok I know the basics about when indexing should be used and the pros and cons of using it.

These are the (only) two ways my queries will look like:

SELECT target_id FROM map WHERE table_name = '' AND fingerprint = '' AND source_id = 1;

and

SELECT fingerprint, source_id FROM map WHERE table_name = '' AND target_id = 1;

I know I have to index fields table_name, fingerprint and source_id going by first query. Also target_id going by the second query. I can do that individually. But I have heard composite keys give better performance if I could index all the fields as one. Since my case is so specific that there wont be another WHERE clause, I thought of creating composite keys like this:

(table_name, fingerprint, source_id)

and

(table_name, target_id)

But since table_name overlaps in both composite indexing, I am unsure if that’s the way to go. Are there performance implications with such overlapping?

When I did some testing, I did not get any performance improvements with either, both were equally fast.I have about only few tens of thousands of records right now, may be thats the reason. But data will scale to millions of records. So I thought of getting expert opinion on it. Thanks.

  • 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-06T12:31:03+00:00Added an answer on June 6, 2026 at 12:31 pm

    In terms of the queries that you’re trying to run, the two indexes that you have are the correct ones. However, I’m not sure about indexing on the table_name field. Indexes on VARCHAR fields tend to be very slow (this answer refers to PostgreSQL, but the underlying concept is the same) and can swell the size of your database, while making INSERTs much slower.

    The solution that I use is to create a lookup table, and if I need a query that will give me the VARCHAR fields, I just run a JOIN on the lookup table. JOINs on INTs tend to be fairly fast and scalable.

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

Sidebar

Related Questions

I know the very basics about using coroutines as a base and implementing a
I want to know about Virtualization in detail. But start from basics, like what
I know basics of UML and java's OO interpretations using class diagrams. But after
I have a problem with operators. Generally I know basics of using operators. But
I really want to learn more about C++. I know the basics, and I
I know the basics about iPhone sdk. I am building an app which is
I already know the basics about functors, how they are created and so on.
I have read the Spring books and know the basics about AOP. I want
I want to know about basics to create ListView. How many methods to use
I have seen the ASP.NET community buzzing about MVC. I know the basics of

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.