-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add function cbdb_relation_size (#428)
Add function cbdb_relation_size It can be used to fetch the size of a batch of relations as below SELECT * FROM cbdb_relation_size((SELECT array_agg(oid) FROM pg_class)); It has better performance than pg_relation_size in such case, more details see the comment on the function Co-authored-by: Xiaoran Wang <wangxiaoran@hashdata.cn>
- Loading branch information
Xiaoran Wang
and
Xiaoran Wang
authored
May 13, 2024
1 parent
2b8815b
commit 27dc124
Showing
6 changed files
with
372 additions
and
1 deletion.
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
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
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
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,44 @@ | ||
-- start_ignore | ||
DROP TABLE IF EXISTS cbdbheapsizetest; | ||
DROP TABLE IF EXISTS cbdbaosizetest; | ||
DROP EXTERNAL TABLE IF EXISTS cbdbsize_t_ext; | ||
-- end_ignore | ||
-- create heap table | ||
CREATE TABLE cbdbheapsizetest(a int); | ||
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table. | ||
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. | ||
INSERT INTO cbdbheapsizetest select generate_series(1, 1000); | ||
-- create ao table | ||
CREATE TABLE cbdbaosizetest (a int) WITH (appendonly=true, orientation=row); | ||
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table. | ||
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. | ||
insert into cbdbaosizetest select generate_series(1, 100000); | ||
-- create EXTERNAL table | ||
CREATE EXTERNAL TABLE cbdbsize_t_ext (a integer) LOCATION ('file://127.0.0.1/tmp/foo') FORMAT 'text'; | ||
WITH cbdbrelsize AS ( | ||
SELECT * | ||
FROM cbdb_relation_size((SELECT array['cbdbsize_t_ext'::regclass,'cbdbheapsizetest'::regclass, 'cbdbaosizetest'::regclass])) | ||
), pgrelsize AS ( | ||
SELECT pg_relation_size(oid) as size, relname, oid FROM pg_class where oid in ('cbdbsize_t_ext'::regclass,'cbdbheapsizetest'::regclass, 'cbdbaosizetest'::regclass) | ||
) | ||
SELECT pgrelsize.relname, pgrelsize.size, cbdbrelsize.size | ||
FROM pgrelsize FULL JOIN cbdbrelsize | ||
ON pgrelsize.oid = cbdbrelsize.reloid | ||
WHERE pgrelsize.size != cbdbrelsize.size; | ||
WARNING: skipping "cbdbsize_t_ext" --- cannot calculate this foreign table size | ||
WARNING: skipping "cbdbsize_t_ext" --- cannot calculate this foreign table size | ||
relname | size | size | ||
---------+------+------ | ||
(0 rows) | ||
|
||
SELECT * FROM cbdb_relation_size(array[]::oid[], 'main'); | ||
reloid | size | ||
--------+------ | ||
(0 rows) | ||
|
||
SELECT size FROM cbdb_relation_size(array['cbdbheapsizetest'::regclass], 'fsm'); | ||
size | ||
------ | ||
0 | ||
(1 row) | ||
|
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
Oops, something went wrong.