Skip to content

Add planner-version flag to vtexplain#8979

Merged
harshit-gangal merged 3 commits intovitessio:mainfrom
planetscale:VTExplainGen4
Oct 15, 2021
Merged

Add planner-version flag to vtexplain#8979
harshit-gangal merged 3 commits intovitessio:mainfrom
planetscale:VTExplainGen4

Conversation

@mattlord
Copy link
Copy Markdown
Member

@mattlord mattlord commented Oct 11, 2021

Description

With Vitess 12.0 we hope to begin migrating more users and workloads from the V3 planner to the new Gen4 planner as it should offer better performance, improved correctness, and additional query language support.

But in order to aid in that effort, users will need a way to try and compare the planner results between the two for their common queries in order to gauge the impact of this migration.

Toward that end, this adds a new -planner-version flag to vtexplain that allows you to get the explain output using the Gen4 planner instead of using the default of V3.

Related Issue(s)

Docs PR: vitessio/website#843

Manual Test/Example

## Invalid version
$ vtexplain -planner-version=Gen5 -shards 2 -schema-file /tmp/schema -vschema-file=/tmp/vschema -sql 'SELECT MAX(co.price) FROM customer c JOIN corder co ON c.customer_id = co.customer_id WHERE c.email != "mlord@planetscale.com" AND co.sku = "foobar" AND co.order_id = 0 GROUP BY co.price'
ERROR: invalid value specified for planner-version of 'Gen5' -- valid values are V3 and Gen4

## V3
$ vtexplain -planner-version=V3 -shards 2 -schema-file /tmp/schema -vschema-file=/tmp/vschema -sql 'SELECT MAX(co.price) FROM customer c JOIN corder co ON c.customer_id = co.customer_id WHERE c.email != "mlord@planetscale.com" AND co.sku = "foobar" AND co.order_id = 0 GROUP BY co.price'
ERROR: vtexplain execute error in 'SELECT MAX(co.price) FROM customer c JOIN corder co ON c.customer_id = co.customer_id WHERE c.email != "mlord@planetscale.com" AND co.sku = "foobar" AND co.order_id = 0 GROUP BY co.price': unsupported: in scatter query: group by column must reference column in SELECT list
1 commerce/-: select c.customer_id from (select customer.customer_id from customer where customer.customer_id = 5) as c join corder on c.customer_id = corder.customer_id limit 10001

----------------------------------------------------------------------

## Gen4
$ vtexplain -planner-version=Gen4 -shards 2 -schema-file /tmp/schema -vschema-file=/tmp/vschema -sql 'SELECT MAX(co.price) FROM customer c JOIN corder co ON c.customer_id = co.customer_id WHERE c.email != "mlord@planetscale.com" AND co.sku = "foobar" AND co.order_id = 0 GROUP BY co.price'
----------------------------------------------------------------------
SELECT MAX(co.price) FROM customer c JOIN corder co ON c.customer_id = co.customer_id WHERE c.email != "mlord@planetscale.com" AND co.sku = "foobar" AND co.order_id = 0 GROUP BY co.price

1 commerce/-80: select MAX(co.price), co.price, weight_string(co.price) from customer as c, corder as co where c.email != 'mlord@planetscale.com' and co.sku = 'foobar' and co.order_id = 0 and c.customer_id = co.customer_id group by co.price, weight_string(co.price) order by co.price asc limit 10001
1 commerce/80-: select MAX(co.price), co.price, weight_string(co.price) from customer as c, corder as co where c.email != 'mlord@planetscale.com' and co.sku = 'foobar' and co.order_id = 0 and c.customer_id = co.customer_id group by co.price, weight_string(co.price) order by co.price asc limit 10001

----------------------------------------------------------------------

Checklist

@mattlord mattlord added Backport me! Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Oct 11, 2021
@mattlord mattlord force-pushed the VTExplainGen4 branch 5 times, most recently from 39bd645 to ba838d2 Compare October 11, 2021 21:15
@mattlord mattlord marked this pull request as ready for review October 11, 2021 21:15
mattlord added a commit to vitessio/website that referenced this pull request Oct 11, 2021
Docs companion to: vitessio/vitess#8979

Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord added a commit to vitessio/website that referenced this pull request Oct 11, 2021
Docs companion to: vitessio/vitess#8979

Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord added a commit to vitessio/website that referenced this pull request Oct 11, 2021
Docs companion to: vitessio/vitess#8979

Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord force-pushed the VTExplainGen4 branch 2 times, most recently from d43c613 to 692ec39 Compare October 11, 2021 22:32
mattlord added a commit to vitessio/website that referenced this pull request Oct 11, 2021
Docs companion to: vitessio/vitess#8979

Signed-off-by: Matt Lord <mattalord@gmail.com>
This allows users to compare the plans generated for v3 and Gen4
in order to better understand the impact of switching versions.

Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
Signed-off-by: Matt Lord <mattalord@gmail.com>
@mattlord mattlord requested a review from frouioui October 13, 2021 16:44
@harshit-gangal harshit-gangal merged commit 0e22c9f into vitessio:main Oct 15, 2021
@harshit-gangal harshit-gangal deleted the VTExplainGen4 branch October 15, 2021 11:10
mattlord added a commit to vitessio/website that referenced this pull request Oct 15, 2021
Docs companion to: vitessio/vitess#8979

Signed-off-by: Matt Lord <mattalord@gmail.com>
mattlord pushed a commit to planetscale/vitess that referenced this pull request Oct 15, 2021
Add planner-version flag to vtexplain

Signed-off-by: Matt Lord <mattalord@gmail.com>
DeathBorn added a commit to vinted/vitess that referenced this pull request Oct 20, 2022
Signed-off-by: Vilius Okockis <vilius.okockis@vinted.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants