You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The proc cpu percent got by gpsmon sometimes is 0 although
the proc cpu cost is not 0. The bug is caused by the
pidtab hash table's key. The key is not pid, but defined
as queryid + pid. In the case a session runs a bunch of
queries, there will be multiple entries in the pidtable
which have the same pid, and the cpu percent will be computed
multiple times for a proc. The cpu percent is computed as
nowcpucost-lastcpucost/timemow-lasttime, then the
nowcpucost-lastcpucost is 0 if it is collected within
a minimal timeframe. Fix that by using pid as the hash
table's key.
By the way, did a small refactor to make the code more
clean.
Copy file name to clipboardExpand all lines: contrib/perfmon/expected/query.out
+21-27Lines changed: 21 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -34,24 +34,20 @@ select sess_id from pg_stat_activity where pg_backend_pid()=pid;
34
34
(1 row)
35
35
36
36
\gset
37
-
-- end_ignore
38
-
CREATE TABLE foo(a int);
37
+
CREATE TABLE foo(a int, b int);
39
38
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table.
40
39
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
41
40
CREATE TABLE test(a int);
42
41
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Cloudberry Database data distribution key for this table.
43
42
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
44
-
INSERT INTO foo SELECT generate_series(0,40000000);
45
-
INSERT INTO test SELECT generate_series(0,40000000);
43
+
\timing
44
+
INSERT INTO foo SELECT i + 1 from generate_series(0,80000000) as i;
45
+
Time: 149935.380 ms (02:29.935)
46
+
\timing
47
+
-- end_ignore
46
48
-- test query text in multiple lines
47
49
INSERT INTO test
48
50
SELECT generate_series(0,10);
49
-
select count(*) from foo,test where foo.a=test.a;
50
-
count
51
-
----------
52
-
40000012
53
-
(1 row)
54
-
55
51
-- test nested query
56
52
create or replace function n_join_foo_test() returns integer as $$
57
53
begin
@@ -61,7 +57,7 @@ $$ language plpgsql;
61
57
select * from n_join_foo_test();
62
58
n_join_foo_test
63
59
-----------------
64
-
40000012
60
+
10
65
61
(1 row)
66
62
67
63
DROP TABLE foo;
@@ -117,29 +113,27 @@ select count(*) > 0 from diskspace_history;
117
113
118
114
select ccnt, status, query_text, length(query_plan) > 0 from queries_history
0 commit comments