Skip to content

Instantly share code, notes, and snippets.

View systay's full-sized avatar

Andrés Taylor systay

View GitHub Profile
Initial tree:
Horizon
└── Union (DISTINCT)
├── Horizon
│ └── Union (DISTINCT)
│ ├── Horizon
│ │ └── Union (DISTINCT)
│ │ ├── Horizon
│ │ │ └── Union (DISTINCT)
│ │ │ ├── Horizon
{
infSchema := map[string]map[string]query.Type{}
cols := map[string]query.Type{}
cols["USER"] = query.Type(6165)
cols["HOST"] = query.Type(6165)
cols["GRANTEE"] = query.Type(6165)
cols["GRANTEE_HOST"] = query.Type(6165)
cols["ROLE_NAME"] = query.Type(6165)
cols["ROLE_HOST"] = query.Type(6165)
cols["IS_GRANTABLE"] = query.Type(6165)
@systay
systay / tpc-h-8.sql
Created December 9, 2022 04:26
The TPC-H Query #8
SELECT O_YEAR, SUM(CASE WHEN NATION = 'BRAZIL' THEN VOLUME ELSE 0 END)/SUM(VOLUME) AS MKT_SHARE
FROM (SELECT datepart(yy,O_ORDERDATE) AS O_YEAR, L_EXTENDEDPRICE*(1-L_DISCOUNT) AS VOLUME, N2.N_NAME AS NATION
FROM PART, SUPPLIER, LINEITEM, ORDERS, CUSTOMER, NATION N1, NATION N2, REGION
WHERE P_PARTKEY = L_PARTKEY AND S_SUPPKEY = L_SUPPKEY AND L_ORDERKEY = O_ORDERKEY
AND O_CUSTKEY = C_CUSTKEY AND C_NATIONKEY = N1.N_NATIONKEY AND
N1.N_REGIONKEY = R_REGIONKEY AND R_NAME = 'AMERICA' AND S_NATIONKEY = N2.N_NATIONKEY
AND O_ORDERDATE BETWEEN '1995-01-01' AND '1996-12-31' AND P_TYPE= 'ECONOMY ANODIZED STEEL') AS ALL_NATIONS
GROUP BY O_YEAR
ORDER BY O_YEAR
| -> Table scan on <temporary> (actual time=0.001..0.002 rows=8 loops=1)
-> Aggregate using temporary table (actual time=0.635..0.637 rows=8 loops=1)
-> Nested loop left join (actual time=0.382..0.555 rows=8 loops=1)
-> Nested loop left join (actual time=0.375..0.532 rows=8 loops=1)
-> Nested loop left join (actual time=0.373..0.526 rows=8 loops=1)
-> Nested loop inner join (actual time=0.367..0.513 rows=8 loops=1)
-> Inner hash join (no condition) (actual time=0.207..0.218 rows=13 loops=1)
-> Table scan on i (cost=0.00 rows=0) (actual time=0.001..0.005 rows=13 loops=1)
-> Fill information schema table i (actual time=0.172..0.177 rows=13 loops=1)
-> Hash
--- FAIL: TestMultipleUpdatesFromDifferentShards/3 (0.04s)
uptate_controller_test.go:170:
Error Trace: uptate_controller_test.go:170
Error: Not equal:
expected: 2
actual : 1
Test: TestMultipleUpdatesFromDifferentShards/3
Messages: signal required
uptate_controller_test.go:172:
Error Trace: uptate_controller_test.go:172
Traditional query optimizing is mostly about two things: in which order and from where to access data, and how to then combine it so it answers the query that the user wrote.
You have problably seen the tree shapes execution plans that are produced from query planning. I'll use an example from the MySQL docs:
mysql> EXPLAIN FORMAT=TREE
-> SELECT *
-> FROM t1
-> JOIN t2
-> ON (t1.c1 = t2.c1 AND t1.c2 < t2.c2)
-> JOIN t3
"select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select col from (select col, id, user_id from user_extra where user_id = 5) uu where uu.user_id = uu.id))"
"unsupported: cross-shard correlated subquery"
{
"QueryType": "SELECT",
"Original": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select col from (select col, id, user_id from user_extra where user_id = 5) uu where uu.user_id = uu.id))",
"Instructions": {
"OperatorType": "Subquery",
"Variant": "PulloutIn",
"Inputs": [
{
2021-06-18T05:20:15.8665971Z ##[section]Starting: Request a runner to run this job
2021-06-18T05:20:15.8930680Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'ubuntu-18.04'
2021-06-18T05:20:15.9163032Z Can't find any online and idle self-hosted runner in current repository's organization account that matches the required labels: 'ubuntu-18.04'
2021-06-18T05:20:15.9737770Z Found online and idle hosted runner in current repository's organization account that matches the required labels: 'ubuntu-18.04'
2021-06-18T05:20:16.0681670Z ##[section]Finishing: Request a runner to run this job
2021-06-18T05:20:21.9347717Z Current runner version: '2.278.0'
2021-06-18T05:20:21.9375285Z ##[group]Operating System
2021-06-18T05:20:21.9376160Z Ubuntu
2021-06-18T05:20:21.9376616Z 18.04.5
2021-06-18T05:20:21.9377051Z LTS
This release complies with VEP-3 which removes the upgrade order requirement. Components can be upgraded in any order. It is recommended that the upgrade order should still be followed if possible, except to canary test the new version of VTGate before upgrading the rest of the components.
## Incompatible Changes
The following PRs made changes to behaviors that clients might rely on. They should be reviewed carefully so that client code can be changed in concert with a Vitess release deployment.
* The update to golang 1.15 (#7204) might break systems that use TLS certificates with a common name. A fix is documented here (https://github.com/golang/go/issues/40748#issuecomment-673612108)
Vitess 9.0 is not compatible with the previous release of the Vitess Kubernetes Operator (2.2.0). A new version of the Operator (2.3.0) is available that is compatible.
## Bugs Fixed
=== RUN TestSetup
I0527 16:50:36.508552 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.549396 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.609755 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.669720 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.745183 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.819824 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.897181 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:36.963496 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []
I0527 16:50:37.008792 69364 engine.go:390] schema engine created [t1_last_insert_id], altered [], dropped []