forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
CREATE DATABASE IF NOT EXISTS TPCH; | ||
USE TPCH; | ||
CREATE TABLE IF NOT EXISTS part ( P_PARTKEY INTEGER NOT NULL, | ||
P_NAME VARCHAR(55) NOT NULL, | ||
P_MFGR CHAR(25) NOT NULL, | ||
P_BRAND CHAR(10) NOT NULL, | ||
P_TYPE VARCHAR(25) NOT NULL, | ||
P_SIZE INTEGER NOT NULL, | ||
P_CONTAINER CHAR(10) NOT NULL, | ||
P_RETAILPRICE DECIMAL(15,2) NOT NULL, | ||
P_COMMENT VARCHAR(23) NOT NULL, | ||
PRIMARY KEY (P_PARTKEY)); | ||
|
||
CREATE TABLE IF NOT EXISTS supplier ( S_SUPPKEY INTEGER NOT NULL, | ||
S_NAME CHAR(25) NOT NULL, | ||
S_ADDRESS VARCHAR(40) NOT NULL, | ||
S_NATIONKEY INTEGER NOT NULL, | ||
S_PHONE CHAR(15) NOT NULL, | ||
S_ACCTBAL DECIMAL(15,2) NOT NULL, | ||
S_COMMENT VARCHAR(101) NOT NULL, | ||
PRIMARY KEY (S_SUPPKEY), | ||
CONSTRAINT FOREIGN KEY SUPPLIER_FK1 (S_NATIONKEY) references nation(N_NATIONKEY)); | ||
|
||
CREATE TABLE IF NOT EXISTS partsupp ( PS_PARTKEY INTEGER NOT NULL, | ||
PS_SUPPKEY INTEGER NOT NULL, | ||
PS_AVAILQTY INTEGER NOT NULL, | ||
PS_SUPPLYCOST DECIMAL(15,2) NOT NULL, | ||
PS_COMMENT VARCHAR(199) NOT NULL, | ||
PRIMARY KEY (PS_PARTKEY,PS_SUPPKEY), | ||
CONSTRAINT FOREIGN KEY PARTSUPP_FK1 (PS_SUPPKEY) references supplier(S_SUPPKEY), | ||
CONSTRAINT FOREIGN KEY PARTSUPP_FK2 (PS_PARTKEY) references part(P_PARTKEY)); | ||
-- load stats. | ||
load stats 's/tpch_stats/part.json'; | ||
load stats 's/tpch_stats/supplier.json'; | ||
load stats 's/tpch_stats/partsupp.json'; | ||
set @@session.tidb_executor_concurrency = 5; | ||
|
||
explain analyze | ||
SELECT MIN(ps_supplycost) over (partition by p_partkey) as min_ps_supplycost, | ||
MAX(ps_supplycost) over (partition by ps_suppkey) as max_ps_supplycost | ||
FROM tpch.part, | ||
tpch.partsupp, | ||
tpch.supplier | ||
WHERE p_partkey = ps_partkey | ||
AND s_suppkey = ps_suppkey | ||
limit 10; |