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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:20:51+00:00 2026-05-26T00:20:51+00:00

So, I have these 2 tables. One contains, lets call them, bugs, and another

  • 0

So, I have these 2 tables. One contains, lets call them, bugs, and another contains solutions. One bug may have more than one solution (or state, if you may), and I’d like to get the last one.

Right now, I’m doing it like this:

Select b.*, ap.approveMistakeId 
from bugs_table as b
LEFT JOIN (select approveId, approveCause, approveDate, approveInfo, 
                  approveUsername, mistakeId as approveMistakeId 
           from approve_table 
           order by approveDate desc) AS ap 
ON m.mistakeId = ap.approveMistakeId 
GROUP BY b.bugId

This is not a complete query, it is just to show the how I’m approaching it. The real query joins more than 10 tables.

The problem with this is, that with this subselect, the query runs for about 3.3s and returns ~2.4K records. Without this query, it runs for 0.4s, which is more acceptable. I have created and index on approveDate, but that didn’t seem to solve the problem.

Could the solution be a view, that was created from this query, and then joined to this query? Or is there a way to do this in some other manner?

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-05-26T00:20:52+00:00Added an answer on May 26, 2026 at 12:20 am

    The problem was the sub-select. The solution – de-normalization. Yes, I know, that isn’t the best solution, but definitely the fastest.

    Tried aggregate self-sorting, but that only added time. Same with joining with a view.

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

Sidebar

Related Questions

I have an array which contains 2 types of items (lets call them type
I have some tables. These tables all have one column in common called 'classified_id':
I have two tables. One contains a list of products with the primary key
Let's say I have two databases with identical tables, but one database's tables contains
I have two tables, let's call them table1 and table2 . They both have
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I have two product tables Product1 and Product2. There is a one 2 one
I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int
I have these tables: Projects(projectID, CreatedByID) Employees(empID,depID) Departments(depID,OfficeID) Offices(officeID) CreatedByID is a foreign key
Suppose you have these tables: Table Name: Salesman Fields: S_ID(Primary Key), Name Table Name:

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.