Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save nicksherron/fca71e218f7c37cc14cd1d6d6fc5d360 to your computer and use it in GitHub Desktop.
mysql: [Warning] Using a password on the command line interface can be insecure.
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| -> Aggregate: json_arrayagg(b.json_object) (actual time=6437.871..6437.876 rows=1 loops=1)
-> Table scan on b (cost=5618.28 rows=49918) (actual time=0.010..2.635 rows=619 loops=1)
-> Materialize CTE b (actual time=6422.562..6430.382 rows=619 loops=1)
-> Nested loop inner join (actual time=2.720..6367.503 rows=619 loops=1)
-> Filter: (<in_optimizer>(product.id,product.id in (select #7)) or <in_optimizer>(product.id,product.id in (select #9))) (cost=9013.37 rows=24959) (actual time=2.432..6254.573 rows=619 loops=1)
-> Table scan on product (cost=9013.37 rows=24959) (actual time=0.052..733.368 rows=35028 loops=1)
-> Select #7 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.id)) (actual time=0.047..0.047 rows=0 loops=35029)
-> Limit: 1 row(s) (actual time=0.029..0.029 rows=0 loops=35029)
-> Index lookup on <materialized_subquery> using <auto_distinct_key> (id=product.id) (actual time=0.010..0.010 rows=0 loops=35029)
-> Materialize with deduplication (cost=2763.36 rows=100) (actual time=0.066..0.066 rows=0 loops=35029)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.587 rows=100 loops=1)
-> Materialize CTE a if needed (cost=2763.36 rows=100) (actual time=0.027..1.684 rows=100 loops=1)
-> Limit: 100 row(s) (cost=2763.36 rows=100) (never executed)
-> Index lookup on product using idx_product_group (group='product'), with index condition: (product.`group` = 'product') (cost=2763.36 rows=12479) (never executed)
-> Select #9 (subquery in condition; run only once)
-> Filter: ((product.id = `<materialized_subquery>`.variant_id)) (actual time=0.047..0.047 rows=0 loops=34929)
-> Limit: 1 row(s) (actual time=0.029..0.029 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=2814.41 rows=259) (actual time=0.066..0.066 rows=0 loops=34929)
-> Nested loop inner join (cost=2814.41 rows=259) (actual time=1.937..13.786 rows=522 loops=1)
-> Table scan on <subquery10> (cost=7.71 rows=100) (actual time=0.009..0.491 rows=100 loops=1)
-> Materialize with deduplication (cost=2763.36 rows=100) (actual time=1.892..3.356 rows=100 loops=1)
-> Table scan on a (cost=13.75 rows=100) (actual time=0.009..0.445 rows=100 loops=1)
-> Materialize CTE a if needed (query plan printed elsewhere) (cost=2763.36 rows=100) (actual time=0.029..1.386 rows=100 loops=1)
-> Index lookup on product_variants using fk_product_variants_product (product_id=`<subquery10>`.id) (cost=25.38 rows=3) (actual time=0.013..0.041 rows=5 loops=100)
-> Materialize table function (actual time=0.144..0.158 rows=1 loops=619)
-> Select #6 (subquery in projection; dependent)
-> Group aggregate: group_concat(product_variants.product_id separator ',') (actual time=0.045..0.049 rows=1 loops=619)
-> Index lookup on product_variants using PRIMARY (variant_id=product.id) (cost=0.36 rows=1) (actual time=0.017..0.021 rows=1 loops=619)
-> Select #2 (subquery in projection; run only once)
-> Rows fetched before execution (cost=0.00 rows=1) (actual time=0.009..0.012 rows=1 loops=1)
|
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment