Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-36348

Query Optimization for Counting Foreign Key Records Not Found in Parent Key even after adding indexes

Details

    • Task
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Not a Bug
    • N/A
    • Optimizer
    • None

    Description

      We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

      What We’ve Tried:

      • NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
      • LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

      What We Need:

      • We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets(Indexes already implemented).

      We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed

      Attachments

        Issue Links

          Activity

            baludbr Balaji Reddy Dwarampudi created issue -
            baludbr Balaji Reddy Dwarampudi made changes -
            Field Original Value New Value
            Description We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            # NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            # LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.
            *What We Need:*
            We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.
            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed.
            We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            # NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            # LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.
            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed.
            baludbr Balaji Reddy Dwarampudi made changes -
            Description We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            # NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            # LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.
            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed.
            We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed.
            baludbr Balaji Reddy Dwarampudi made changes -
            Description We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed.
            We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed(i need data in seconds)
            baludbr Balaji Reddy Dwarampudi made changes -
            Description We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed(i need data in seconds)
            We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed
            baludbr Balaji Reddy Dwarampudi made changes -
            Description We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets.

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed
            We are facing performance issues when trying to count the number of records in the foreign key column that don’t have a corresponding value in the parent table’s primary key. While we already have the total row count, the query still takes too long to run, especially with large datasets.

            *What We’ve Tried:*
            * NOT EXISTS Query: We tried using a NOT EXISTS query, but it still took too long to execute.
            * LEFT JOIN Query: We also tried using a LEFT JOIN with a NULL check on the parent table, but the performance was still suboptimal.

             
            *What We Need:*
            * We need a more efficient approach to count the records where the foreign key exists in the child table but doesn’t have a corresponding primary key in the parent table. The current methods are still taking longer than expected with larger datasets(Indexes already implemented).

            We would appreciate suggestions on how to optimize this query further. Whether it’s through other query techniques, we are open to solutions that can improve speed
            baludbr Balaji Reddy Dwarampudi made changes -
            Summary Query Optimization for Counting Foreign Key Records Not Found in Parent Key Query Optimization for Counting Foreign Key Records Not Found in Parent Key even after adding indexes
            marko Marko Mäkelä made changes -
            serg Sergei Golubchik made changes -
            Component/s Optimizer [ 10200 ]
            Fix Version/s N/A [ 14700 ]
            Resolution Not a Bug [ 6 ]
            Status Open [ 1 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Priority Blocker [ 1 ] Minor [ 4 ]

            People

              Unassigned Unassigned
              baludbr Balaji Reddy Dwarampudi
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.