Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Created January 21, 2022 07:54
Show Gist options
  • Select an option

  • Save nicksherron/34cd977552b14ae8e8ce6d234bac24ae to your computer and use it in GitHub Desktop.

Select an option

Save nicksherron/34cd977552b14ae8e8ce6d234bac24ae to your computer and use it in GitHub Desktop.
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Aggregate: count(0), json_arrayagg(b.json_object) (actual time=1207.051..1207.055 rows=1 loops=1)
-> Table scan on b (cost=846.48 rows=7502) (actual time=0.022..2.828 rows=619 loops=1)
-> Materialize CTE b (actual time=1190.853..1199.170 rows=619 loops=1)
-> Nested loop inner join (actual time=5.385..1125.968 rows=619 loops=1)
-> Filter: (<in_optimizer>(product.id,product.id in (select #4)) or <in_optimizer>(product.id,product.id in (select #6))) (cost=607.35 rows=3751) (actual time=5.169..976.023 rows=619 loops=1)
-> Table scan on product (cost=607.35 rows=3751) (actual time=0.023..31.423 rows=4124 loops=1)
-> Select #4 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.id)) (actual time=0.054..0.054 rows=0 loops=4125)
-> Limit: 1 row(s) (actual time=0.033..0.033 rows=0 loops=4125)
-> Index lookup on <materialized_subquery> using <auto_distinct_key> (id=product.id) (actual time=0.012..0.012 rows=0 loops=4125)
-> Materialize with deduplication (cost=175.68 rows=100) (actual time=0.077..0.077 rows=0 loops=4125)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.491 rows=100 loops=1)
-> Materialize CTE a if needed (cost=175.68 rows=100) (actual time=3.142..4.563 rows=100 loops=1)
-> Limit: 100 row(s) (cost=175.68 rows=100) (actual time=0.037..2.075 rows=100 loops=1)
-> Index lookup on product using idx_product_group (group='product'), with index condition: (product.`group` = 'product') (cost=175.68 rows=819) (actual time=0.018..1.135 rows=100 loops=1)
-> Select #6 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.variant_id)) (actual time=0.056..0.056 rows=0 loops=4025)
-> Limit: 1 row(s) (actual time=0.034..0.034 rows=0 loops=4025)
-> Index lookup on <materialized_subquery> using <auto_distinct_key> (variant_id=product.id) (actual time=0.012..0.012 rows=0 loops=4025)
-> Materialize with deduplication (cost=33774.70 rows=331100) (actual time=0.126..0.126 rows=0 loops=4025)
-> Nested loop inner join (cost=33774.70 rows=331100) (actual time=1.960..193.935 rows=522 loops=1)
-> Index scan on product_variants using fk_product_variants_product (cost=333.60 rows=3311) (actual time=0.022..19.816 rows=3309 loops=1)
-> Single-row index lookup on <subquery7> using <auto_distinct_key> (id=product_variants.product_id) (actual time=0.011..0.012 rows=0 loops=3309)
-> Materialize with deduplication (cost=175.68 rows=100) (actual time=0.033..0.035 rows=0 loops=3309)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.440 rows=100 loops=1)
-> Materialize CTE a if needed (query plan printed elsewhere) (cost=175.68 rows=100) (actual time=0.026..1.361 rows=100 loops=1)
-> Materialize table function (actual time=0.197..0.213 rows=1 loops=619)
-> Select #3 (subquery in projection; dependent)
-> Group aggregate: group_concat(product_variants.product_id separator ',') (actual time=0.054..0.059 rows=1 loops=619)
-> Index lookup on product_variants using PRIMARY (variant_id=product.id) (cost=7.00 rows=67) (actual time=0.020..0.025 rows=1 loops=619)
|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment