Home Database Mysql Tutorial 统计对象大小信息的函数和子查询的Bug

统计对象大小信息的函数和子查询的Bug

Jun 07, 2016 pm 04:04 PM
bug information function size object Inquire statistics

I hava below two statement sql: 0. not in subquery select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b); 1. in subquery select a.

I hava below two statement sql:
0. not in subquery
select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);
1. in subquery
select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);

The [0. not in subquery] can't work well, it's occur error:
ERROR: query plan with multiple segworker groups is not supported (cdbdisp.c:500)
HINT: likely caused by a function that reads or modifies data in a distributed table
CONTEXT: SQL statement "select sum(pg_total_relation_size('information_schema.sql_languages'))::int8 from gp_dist_random('gp_id');"

The [1. in subquery] work well.

Detailed below test:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

gtlions=# select version();

version

------------------------------------------------------------------------------------------------------------------------------------------------------

PostgreSQL 8.2.15 (Greenplum Database 4.2.7.3 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on May 7 2014 14:31:08

(1 row)

 

gtlions=# select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);

ERROR: query plan with multiple segworker groups is not supported (cdbdisp.c:500)

HINT: likely caused by a function that reads or modifies data in a distributed table

CONTEXT: SQL statement "select sum(pg_total_relation_size('information_schema.sql_languages'))::int8 from gp_dist_random('gp_id');"

gtlions=# explain select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);

QUERY PLAN

-----------------------------------------------------------------------------------------------

Hash Left Anti Semi Join (cost=568.98..235912.69 rows=676396 width=128)

Hash Cond: c.relname = "NotIn_SUBQUERY".tablename::name

-> Hash Left Join (cost=395.97..223194.68 rows=676419 width=128)

Hash Cond: c.relnamespace = n.oid

-> Hash Left Join (cost=2.62..112777.67 rows=676419 width=68)

Hash Cond: c.reltablespace = t.oid

-> Seq Scan on pg_class c (cost=0.00..2751.39 rows=676419 width=72)

Filter: relkind = 'r'::"char" AND relname IS NOT NULL

-> Hash (cost=1.02..1.02 rows=2 width=4)

-> Seq Scan on pg_tablespace t (cost=0.00..1.02 rows=128 width=4)

-> Hash (cost=365.35..365.35 rows=35 width=68)

-> Seq Scan on pg_namespace n (cost=0.00..365.35 rows=2240 width=68)

-> Hash (cost=106.61..106.61 rows=83 width=274)

-> Gather Motion 64:1 (slice1; segments: 64) (cost=0.00..106.61 rows=83 width=274)

-> Subquery Scan "NotIn_SUBQUERY" (cost=0.00..52.66 rows=2 width=274)

-> Seq Scan on t b (cost=0.00..51.83 rows=2 width=24)

(16 rows)

 

gtlions=# select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);

schemaname | size-1

-------------+---------

public | 32 kB

public | 32 kB

......

......

public | 96 kB

gtlions=# explain select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);

QUERY PLAN

---------------------------------------------------------------------------------------------------------------------------------

Gather Motion 64:1 (slice7; segments: 64) (cost=445.41..10096.03 rows=1 width=128)

-> Hash Left Join (cost=445.41..10096.03 rows=1 width=128)

Hash Cond: c.reltablespace = t.oid

-> Redistribute Motion 64:64 (slice5; segments: 64) (cost=443.06..10092.81 rows=1 width=132)

Hash Key: c.reltablespace

-> Hash Left Join (cost=443.06..10092.22 rows=1 width=132)

Hash Cond: c.relnamespace = n.oid

-> Redistribute Motion 64:64 (slice3; segments: 64) (cost=54.53..9703.24 rows=1 width=72)

Hash Key: c.relnamespace

-> Hash EXISTS Join (cost=54.53..9702.65 rows=1 width=72)

Hash Cond: c.relname = b.tablename::name

-> Redistribute Motion 1:64 (slice1) (cost=0.00..9621.26 rows=10570 width=72)

Hash Key: c.relname

-> Seq Scan on pg_class c (cost=0.00..2751.39 rows=676419 width=72)

Filter: relkind = 'r'::"char"

-> Hash (cost=53.49..53.49 rows=2 width=24)

-> Redistribute Motion 64:64 (slice2; segments: 64) (cost=0.00..53.49 rows=2 width=24)

Hash Key: b.tablename::name

-> Seq Scan on t b (cost=0.00..51.83 rows=2 width=24)

-> Hash (cost=388.10..388.10 rows=1 width=68)

-> Redistribute Motion 1:64 (slice4) (cost=0.00..388.10 rows=35 width=68)

Hash Key: n.oid

-> Seq Scan on pg_namespace n (cost=0.00..365.35 rows=2240 width=68)

-> Hash (cost=2.32..2.32 rows=1 width=4)

-> Redistribute Motion 1:64 (slice6) (cost=0.00..2.32 rows=2 width=4)

Hash Key: t.oid

-> Seq Scan on pg_tablespace t (cost=0.00..1.02 rows=128 width=4)

(27 rows)

Copy after login



该问题应该是个Bug,等待TSE给出Fix或者没有Fix而只能等到下个版本升级了.
-EOF-
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

Apple iOS18 bug summary Apple iOS18 bug summary Jun 14, 2024 pm 01:48 PM

As Apple's WWDC conference 2024 came to a successful conclusion, not only macos15 was announced, but the update of Apple's new iOS18 system attracted the most attention. Although there are many new features, as the first version of Apple's iOS18, people inevitably wonder whether it is necessary to upgrade Apple. iOS18, what kind of bugs are there in the latest release of Apple iOS18? After real use evaluation, the following is a summary of Apple iOS18 bugs, let’s take a look. Currently, many iPhone users are rushing to upgrade to iOS18. However, various system bugs are making people uncomfortable. Some bloggers said that you should be cautious when upgrading to iOS18 because "there are so many bugs." The blogger said that if your iPhone is

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

How to convert MySQL query result array to object? How to convert MySQL query result array to object? Apr 29, 2024 pm 01:09 PM

Here's how to convert a MySQL query result array into an object: Create an empty object array. Loop through the resulting array and create a new object for each row. Use a foreach loop to assign the key-value pairs of each row to the corresponding properties of the new object. Adds a new object to the object array. Close the database connection.

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Comparison of the advantages and disadvantages of C++ function default parameters and variable parameters Apr 21, 2024 am 10:21 AM

The advantages of default parameters in C++ functions include simplifying calls, enhancing readability, and avoiding errors. The disadvantages are limited flexibility and naming restrictions. Advantages of variadic parameters include unlimited flexibility and dynamic binding. Disadvantages include greater complexity, implicit type conversions, and difficulty in debugging.

What is the difference between custom PHP functions and predefined functions? What is the difference between custom PHP functions and predefined functions? Apr 22, 2024 pm 02:21 PM

The difference between custom PHP functions and predefined functions is: Scope: Custom functions are limited to the scope of their definition, while predefined functions are accessible throughout the script. How to define: Custom functions are defined using the function keyword, while predefined functions are defined by the PHP kernel. Parameter passing: Custom functions receive parameters, while predefined functions may not require parameters. Extensibility: Custom functions can be created as needed, while predefined functions are built-in and cannot be modified.

See all articles