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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:05:02+00:00 2026-05-21T11:05:02+00:00

The following query isn’t efficient and I need to make it run much faster.

  • 0

The following query isn’t efficient and I need to make it run much faster.

id  select_type table   type    possible_keys   key key_len ref rows    Extra
1   PRIMARY sob_datas   ALL sob_form_id,sob_form_id_2   NULL    NULL    NULL    365990  Using where
2   DEPENDENT SUBQUERY  sub_sob_datas   ALL sob_form_id,sob_form_id_2   NULL    NULL    NULL    365990  Using where

How can I optimize this query? sob_field_value is a text field

I’m pulling fields in each of these forms that have different values.

SELECT
                sob_datas.id,
                sob_datas.sob_field_name,
                sob_datas.sob_field_value
            FROM sob_datas
            WHERE sob_form_id = '.$proof['SobForm']['id'].' AND
            EXISTS(
                    SELECT
                        sub_sob_datas.id
                    FROM sob_datas AS sub_sob_datas
                    WHERE sub_sob_datas.sob_form_id = '.$original['SobForm']['id'].' AND
                    sub_sob_datas.sob_field_name = sob_datas.sob_field_name AND
                    sub_sob_datas.sob_field_value != sob_datas.sob_field_value
            )

I should also point out, I’m going to update only the changed fields with the new values

  • 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-21T11:05:03+00:00Added an answer on May 21, 2026 at 11:05 am

    It is hard to wrap your head around what is trying to be done here 🙂 So hopefully I caught the point and this is what you are looking for / works. If not let me know and I will try and figure it out.

    A bit of test data may help the process along (5-10 rows or so) and what is expected to be fetched from those rows. But here is my shot at it:

        SELECT
                sob_datas.id,
                sob_datas.sob_field_name,
                sob_datas.sob_field_value
        FROM sob_datas sd 
            JOIN sob_datas ssd ON sd.sob_field_name = ssd.sob_field_name
        WHERE sd.sob_form_id = '.$proof['SobForm']['id'].' 
            AND sd.sob_field_value != ssd.sob_datas.sob_field_value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query: select column_name, count(column_name) from table group by column_name having
If I run the following query in SQL Server 2000 Query Analyzer: BULK INSERT
The following SQL query isn't working. I think the error is on the first
Please check out the following query. The SQL isn't as bad as it looks.
Although I know this isn't very efficient, I need to get this working fast
The following query is showing same user for multiple times, how to make it
The following query returns strange results for me: SELECT `Statistics`.`StatisticID`, COUNT(`Votes`.`StatisticID`) AS `Score`, COUNT(`Views`.`StatisticID`)
The following query does what I'd like it to do, however, I have no
The following query will display all Dewey Decimal numbers that have been duplicated in
Using the following query and results, I'm looking for the most recent entry where

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.