mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-09-07 22:18:57 +00:00
* refactor: simplify scan projection to root column indices Signed-off-by: fys <fengys1996@gmail.com> * fix: sqlness test Signed-off-by: fys <fengys1996@gmail.com> * chore: code style adjust Signed-off-by: fys <fengys1996@gmail.com> * fix: cr Signed-off-by: fys <fengys1996@gmail.com> * add comment and test Signed-off-by: fys <fengys1996@gmail.com> * minor change Signed-off-by: fys <fengys1996@gmail.com> * fix: unit test Signed-off-by: fys <fengys1996@gmail.com> --------- Signed-off-by: fys <fengys1996@gmail.com>
101 lines
6.6 KiB
Plaintext
101 lines
6.6 KiB
Plaintext
CREATE TABLE ssts_limit_case (
|
|
a INT PRIMARY KEY INVERTED INDEX,
|
|
b STRING SKIPPING INDEX,
|
|
c STRING FULLTEXT INDEX,
|
|
ts TIMESTAMP TIME INDEX,
|
|
)
|
|
PARTITION ON COLUMNS (a) (
|
|
a < 1000,
|
|
a >= 1000 AND a < 2000,
|
|
a >= 2000
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO ssts_limit_case VALUES
|
|
(500, 'a', 'a', 1),
|
|
(1500, 'b', 'b', 2),
|
|
(2500, 'c', 'c', 3);
|
|
|
|
Affected Rows: 3
|
|
|
|
ADMIN FLUSH_TABLE('ssts_limit_case');
|
|
|
|
+--------------------------------------+
|
|
| ADMIN FLUSH_TABLE('ssts_limit_case') |
|
|
+--------------------------------------+
|
|
| 0 |
|
|
+--------------------------------------+
|
|
|
|
SELECT COUNT(DISTINCT node_id) > 1 AS has_multi_datanodes
|
|
FROM information_schema.ssts_manifest;
|
|
|
|
+---------------------+
|
|
| has_multi_datanodes |
|
|
+---------------------+
|
|
| true |
|
|
+---------------------+
|
|
|
|
SELECT COUNT(*) AS limited_rows
|
|
FROM (
|
|
SELECT region_id
|
|
FROM information_schema.ssts_manifest
|
|
LIMIT 1
|
|
);
|
|
|
|
+--------------+
|
|
| limited_rows |
|
|
+--------------+
|
|
| 1 |
|
|
+--------------+
|
|
|
|
SELECT COUNT(*) AS filtered_limited_rows
|
|
FROM (
|
|
SELECT region_id
|
|
FROM information_schema.ssts_manifest
|
|
WHERE region_id > 0
|
|
LIMIT 1
|
|
);
|
|
|
|
+-----------------------+
|
|
| filtered_limited_rows |
|
|
+-----------------------+
|
|
| 1 |
|
|
+-----------------------+
|
|
|
|
-- SQLNESS REPLACE (RepartitionExec:.*) RepartitionExec: REDACTED
|
|
EXPLAIN SELECT COUNT(*) AS filtered_limited_rows
|
|
FROM (
|
|
SELECT region_id
|
|
FROM information_schema.ssts_manifest
|
|
WHERE table_id > 0
|
|
LIMIT 1
|
|
);
|
|
|
|
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| plan_type | plan |
|
|
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| logical_plan | MergeScan [is_placeholder=false, remote_input=[ |
|
|
| | Projection: count(Int64(1)) AS count(*) AS filtered_limited_rows |
|
|
| | Aggregate: groupBy=[[]], aggr=[[count(Int64(1))]] |
|
|
| | Limit: skip=0, fetch=1 |
|
|
| | Projection: information_schema.ssts_manifest.region_id |
|
|
| | Filter: information_schema.ssts_manifest.table_id > UInt32(0) |
|
|
| | TableScan: information_schema.ssts_manifest, partial_filters=[information_schema.ssts_manifest.table_id > UInt32(0)] |
|
|
| | ]] |
|
|
| physical_plan | ProjectionExec: expr=[count(Int64(1))@0 as filtered_limited_rows] |
|
|
| | AggregateExec: mode=Final, gby=[], aggr=[count(Int64(1))] |
|
|
| | CoalescePartitionsExec |
|
|
| | AggregateExec: mode=Partial, gby=[], aggr=[count(Int64(1))] |
|
|
| | CoalescePartitionsExec: fetch=1 |
|
|
| | FilterExec: table_id@0 > 0, projection=[], fetch=1 |
|
|
| | RepartitionExec: REDACTED
|
|
| | DistributedInspectExec: kind=SstManifest, scan=ScanRequest { projection: [2], filters: [table_id > UInt32(0)] }, schema=Schema { fields: [Field { name: "table_id", data_type: UInt32 }], metadata: {"greptime:version": "0"} } |
|
|
| | |
|
|
+---------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
DROP TABLE ssts_limit_case;
|
|
|
|
Affected Rows: 0
|
|
|