Skip to content

Instantly share code, notes, and snippets.

@nicksherron
Created January 21, 2022 08:36
Show Gist options
  • Select an option

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

Select an option

Save nicksherron/f1618183c057e12164b09531fa3a0da9 to your computer and use it in GitHub Desktop.
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Table scan on <union temporary> (cost=2.50 rows=0) (actual time=0.008..0.015 rows=2 loops=1)
-> Union materialize with deduplication (actual time=6701.814..6701.836 rows=2 loops=1)
-> Aggregate: json_arrayagg(b.json_object) (actual time=6674.638..6674.643 rows=1 loops=1)
-> Table scan on b (cost=5618.28 rows=49918) (actual time=0.011..3.311 rows=619 loops=1)
-> Materialize CTE b (actual time=6629.886..6639.669 rows=619 loops=1)
-> Nested loop inner join (actual time=5.242..6533.189 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=7356.57 rows=24959) (actual time=4.972..6393.923 rows=619 loops=1)
-> Table scan on product (cost=7356.57 rows=24959) (actual time=0.022..615.893 rows=35028 loops=1)
-> Select #4 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.id)) (actual time=0.049..0.049 rows=0 loops=35029)
-> Limit: 1 row(s) (actual time=0.030..0.030 rows=0 loops=35029)
-> Index lookup on <materialized_subquery> using <auto_distinct_key> (id=product.id) (actual time=0.011..0.011 rows=0 loops=35029)
-> Materialize with deduplication (cost=2378.12 rows=100) (actual time=0.069..0.069 rows=0 loops=35029)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.439 rows=100 loops=1)
-> Materialize CTE a if needed (cost=2378.12 rows=100) (actual time=3.054..4.336 rows=100 loops=1)
-> Limit: 100 row(s) (cost=2378.12 rows=100) (actual time=0.038..1.995 rows=100 loops=1)
-> Index lookup on product using idx_product_group (group='product'), with index condition: (product.`group` = 'product') (cost=2378.12 rows=12479) (actual time=0.022..1.037 rows=100 loops=1)
-> Select #6 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.variant_id)) (actual time=0.049..0.049 rows=0 loops=34929)
-> Limit: 1 row(s) (actual time=0.030..0.030 rows=0 loops=34929)
-> Index lookup on <materialized_subquery> using <auto_distinct_key> (variant_id=product.id) (actual time=0.010..0.010 rows=0 loops=34929)
-> Materialize with deduplication (cost=2499.66 rows=259) (actual time=0.069..0.069 rows=0 loops=34929)
-> Nested loop inner join (cost=2499.66 rows=259) (actual time=1.840..15.926 rows=522 loops=1)
-> Table scan on <subquery7> (cost=7.71 rows=100) (actual time=0.009..0.439 rows=100 loops=1)
-> Materialize with deduplication (cost=2378.12 rows=100) (actual time=1.800..3.181 rows=100 loops=1)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.426 rows=100 loops=1)
-> Materialize CTE a if needed (query plan printed elsewhere) (cost=2378.12 rows=100) (actual time=0.027..1.283 rows=100 loops=1)
-> Index lookup on product_variants using fk_product_variants_product (product_id=`<subquery7>`.id) (cost=95.86 rows=3) (actual time=0.024..0.056 rows=5 loops=100)
-> Materialize table function (actual time=0.185..0.200 rows=1 loops=619)
-> Select #3 (subquery in projection; dependent)
-> Group aggregate: group_concat(product_variants.product_id separator ',') (actual time=0.052..0.056 rows=1 loops=619)
-> Index lookup on product_variants using PRIMARY (variant_id=product.id) (cost=1.09 rows=1) (actual time=0.020..0.028 rows=1 loops=619)
-> Aggregate: count(0) (actual time=2.031..2.035 rows=1 loops=1)
-> Table scan on v (cost=13.75 rows=100) (actual time=0.009..0.568 rows=100 loops=1)
-> Materialize CTE a if needed (query plan printed elsewhere) (cost=2378.12 rows=100) (actual time=0.032..1.494 rows=100 loops=1)
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment