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

  • Home
  • SEARCH
  • 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 9224805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:25:04+00:00 2026-06-18T04:25:04+00:00

I got the following problem with my MySQL 5.5 DB – i am pretty

  • 0

I got the following problem with my MySQL 5.5 DB – i am pretty new to this so it might be very obvious whats wrong but i just cant seem to get it:

Two tables:


Table1

CREATE TABLE `sequence_matches` (
    `Sample_ID` INT(6) NOT NULL,
    `Sequence_Match_ID` INT(8) NOT NULL,
    `Start` INT(6) NULL DEFAULT NULL,
    `End` INT(6) NULL DEFAULT NULL,
    `Coverage` DOUBLE(5,2) NULL DEFAULT NULL,
    `Frag_String` VARCHAR(255) NULL DEFAULT NULL,
    `rms_mass_error_prod` DOUBLE(10,4) NULL DEFAULT NULL,
    `rms_rt_error_prod` DOUBLE(10,4) NULL DEFAULT NULL,
  PRIMARY KEY (`Sample_ID`, `Sequence_Match_ID`)
)

and


Table 2

CREATE TABLE `peptide_identifications` (
   `Sample_ID` INT(6) NOT NULL,
   `Peptide_identification_ID` INT(8) NOT NULL,
   `Mass_error` DOUBLE(10,4) NULL DEFAULT NULL,
   `Mass_error_ppm` DOUBLE(10,4) NULL DEFAULT NULL,
   `Score` DOUBLE(10,4) NULL DEFAULT NULL,
   `Type` VARCHAR(45) NULL DEFAULT NULL,
   `global_pept_ID` INT(8) NOT NULL,
  PRIMARY KEY (`Sample_ID`, `Peptide_identification_ID`),
  INDEX `Index` (`global_pept_ID`)
)

each of them contains ~15 million rows.

Now, i want all those rows from Table2 where global_pept_id = 27443 and then use the peptide_identification_id of those, to query all information from Table1 where peptide_identification_id = sequence_match_id.

I tried the following statement:

SELECT * from sequence_matches 
JOIN (
  SELECT peptide_identification_id 
  FROM peptide_identifications 
  WHERE global_pept_id = 27443
) as tmp_pept 
ON sequence_match_id = peptide_identification_id; 

Here the Explain for that query:

https://i.stack.imgur.com/QV3ER.jpg (click to enlarge)

Now this query is very, very slow (i actually never finished it, stopepd it after ~10min) and i can imagine it’s because there is no Index used for the second table although both ID’s are primary key and thus they should be indexed right?

The results for the inner select require ~3 sek and return ~3k rows if performed alone. So the i think the problem is making 3000 * 15mio compares cause every row is checked in Table2.

But how do i fix this?

any help appreciated
-voiD

  • 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-18T04:25:06+00:00Added an answer on June 18, 2026 at 4:25 am

    Slightly different than other solutions. Consider the primary criteria you are trying to get first… those peptide elements for a given global peptide value. Ensure you have an index on this table on any such criteria you may be querying against (which you have). However, if you find you will be querying on more than one WHERE condition against the same table, try to prepare/have an index that will help on BOTH criteria.

    Then, put a JOIN condition to the other table on the PK/FK relationship to get those records.

    SELECT * 
       from 
          peptide_identification PI
             JOIN sequence_matches SM
                ON PI.peptide_identification_id = SM.sequence_match_id
       WHERE 
          PI.global_pept_id = 27443
    

    Without having proper indexes can significantly kill a query’s performance. Your Sequence_Matches table should have an index on just (Sequence_match_ID) to help its optimization. Having it in the second position (after the sample_id), will not benefit as expected.

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

Sidebar

Related Questions

I'm just changing my website's MySQL to PDO, and I've got a strange problem
I'm having a pretty weird problem with PHP and MySQL. I'm doing the following
I'm struggling with the following problem concerning primary ids within mysql: I got an
Well my problem is pretty simple, i got the following includes: #include stdafx.h #include
Hello i got a problem with my mysql code it gives the following error
I've got following problem: (c#) There is some class (IRC bot), which has method,
Ive got the following problem. I have a model called user which has a
I got the following problem: In my Android App I am using a table
I've got the following problem: I have two tables: (simplified) +--------+ +-----------+ | User
In Eclipse UI, I got the following problem, If you see left side, the

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.