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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:51:43+00:00 2026-05-27T17:51:43+00:00

So, here’s a question that will probably have the SQL experts jumping all over

  • 0

So, here’s a question that will probably have the SQL experts jumping all over me calling me lazy, but I’m stumped. Our online store crashed and burned this morning, and here is the suspect query. I’ve thought about this all day, and haven’t come up with any genius optimizations. Can I get some help? Any crucial indexes? Ways to restructure this? I realize this is like asking what’s on the other side of the wall and then giving you a telescope pointed the other direction, but figured it was worth a shot:

SELECT DISTINCT (SELECT filename FROM (SELECT DISTINCT y.value AS label, x.value AS filename 
                        FROM   `catalog_product_super_link` AS z 
                        INNER JOIN `catalog_product_entity_varchar` AS y 
                        ON z.product_id = y.entity_id 
                        INNER JOIN `catalog_product_entity_varchar` AS x 
                        ON z.product_id = x.entity_id 
                        WHERE  parent_id = (SELECT entity_id 
                                             FROM   `catalog_product_entity`
                                             WHERE  sku LIKE 'F11-ARC-7710%' 
                                             LIMIT  0, 1) 
                        AND y.attribute_id = (SELECT attribute_id 
                                               FROM   `eav_attribute` 
                                               WHERE  attribute_code = 'image_label' 
                                               AND entity_type_id = (SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'catalog_product') LIMIT 0, 1) 
                        AND x.attribute_id = (SELECT attribute_id 
                                               FROM   `eav_attribute` 
                                               WHERE  attribute_code = 'image' 
                                               AND entity_type_id = (SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'catalog_product'))) AS images WHERE c.value LIKE CONCAT(label,'%') LIMIT 0, 1) AS image,
                        pricing_value, 
                        is_percent, 
                        value_index, 
                        c.value AS label,
                        d.sort_order AS sort_order
                        FROM   `catalog_product_super_attribute_pricing` AS a 
                        INNER JOIN `catalog_product_super_attribute_label` AS b 
                        ON a.product_super_attribute_id = b.product_super_attribute_id 
                        INNER JOIN `eav_attribute_option_value` AS c 
                        ON value_index = c.option_id 
                        INNER JOIN `eav_attribute_option` AS d
                        ON c.option_id = d.option_id 
                        WHERE  a.product_super_attribute_id = (SELECT product_super_attribute_id 
                                                               FROM   `catalog_product_super_attribute` 
                                                               WHERE  product_id = 5928 
                                                               AND attribute_id = 143 LIMIT 0, 1) 

                        UNION ALL

                        SELECT DISTINCT (SELECT filename FROM (SELECT DISTINCT y.value AS label, x.value AS filename 
                                         FROM   `catalog_product_super_link` AS z 
                                         INNER JOIN `catalog_product_entity_varchar` AS y 
                                         ON z.product_id = y.entity_id 
                                         INNER JOIN `catalog_product_entity_varchar` AS x 
                                         ON z.product_id = x.entity_id 
                                         WHERE  parent_id = (SELECT entity_id 
                                                             FROM   `catalog_product_entity`
                                                             WHERE  sku LIKE 'F11-ARC-7710%' 
                                                             LIMIT  0, 1) 
                                         AND y.attribute_id = (SELECT attribute_id 
                                                               FROM   `eav_attribute`
                                                               WHERE  attribute_code = 'image_label' 
                                                               AND entity_type_id = (SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'catalog_product') LIMIT 0, 1) 
                                         AND x.attribute_id = (SELECT attribute_id 
                                                               FROM   `eav_attribute` 
                                                               WHERE  attribute_code = 'image' 
                                                               AND entity_type_id = (SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'catalog_product'))) AS images
                                                               WHERE label LIKE CONCAT((SELECT value FROM `eav_attribute_option_value` WHERE option_id = c.value LIMIT 0, 1),'%') LIMIT 0, 1) AS image,
                                        0 AS pricing_value, 
                                        0 AS is_percent, 
                                        c.value AS value_index, 
                                        (SELECT value FROM `eav_attribute_option_value` WHERE  option_id = c.value LIMIT  0, 1) AS label,
                                        (SELECT sort_order FROM `eav_attribute_option` WHERE option_id = c.value LIMIT 0, 1) AS sort_order
                        FROM   `catalog_product_entity` AS a 
                        INNER JOIN `cataloginventory_stock_status` AS b 
                        ON a.entity_id = b.product_id 
                        INNER JOIN `catalog_product_entity_int` AS c 
                        ON a.entity_id = c.entity_id 
                        INNER JOIN `cataloginventory_stock_item` AS d 
                        ON a.entity_id = d.product_id 
                        WHERE  c.attribute_id = (SELECT attribute_id 
                                                 FROM   `eav_attribute` 
                                                 WHERE  attribute_code = 'choose_size' 
                                                 AND entity_type_id = (SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'catalog_product') LIMIT 0, 1) 
                        AND a.entity_id IN (SELECT DISTINCT product_id 
                                            FROM   `catalog_product_super_link` 
                                            WHERE  parent_id = (SELECT entity_id FROM `catalog_product_entity` WHERE sku LIKE 'F11-ARC-7710%' LIMIT  0, 1)) 
                        AND (b.qty > 0 OR d.manage_stock = 0) 
                        AND (SELECT value 
                             FROM   `eav_attribute_option_value` 
                             WHERE  option_id = c.value 
                             LIMIT  0, 1) NOT IN (SELECT c.value 
                                                  FROM `catalog_product_super_attribute_pricing` AS a
                                                  INNER JOIN `catalog_product_super_attribute_label` AS b ON a.product_super_attribute_id = b.product_super_attribute_id 
                                                  INNER JOIN `eav_attribute_option_value` AS c ON value_index = c.option_id 
                                                  WHERE  a.product_super_attribute_id = (SELECT product_super_attribute_id FROM `catalog_product_super_attribute`
                                                                                 WHERE product_id = 5928 
                                                                                         AND attribute_id = 143))
                        ORDER BY sort_order

Thanks in advance!

  • 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-27T17:51:44+00:00Added an answer on May 27, 2026 at 5:51 pm

    A quick response.

    Can you do it in the equivilent of PLSQL?
    Can you eliminate those subqueries?

    Do them first and store the results.
    Assuming that they return a single row.

    Then, write a smaller query passing in the variables.

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

Sidebar

Related Questions

Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is the scenario: I'm writing an app that will watch for any changes
Here is my code (Say we have a single button on the page that
Here is my problem...I have a page that loads a list of clients and
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here's a coding problem for those that like this kind of thing. Let's see
Here we go again, the old argument still arises... Would we better have a
Here's the basic setup: I have a thin bar at the top of a

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.