search
HomeDatabaseMysql Tutorial统计对象大小信息的函数和子查询的Bug
统计对象大小信息的函数和子查询的BugJun 07, 2016 pm 04:04 PM
buginformationfunctionsizeobjectInquirestatistics

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:

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) 



该问题应该是个Bug,等待TSE给出Fix或者没有Fix而只能等到下个版本升级了.
-EOF-
Statement
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
如何在uniapp中实现数据统计和分析如何在uniapp中实现数据统计和分析Oct 24, 2023 pm 12:37 PM

如何在uniapp中实现数据统计和分析一、背景介绍数据统计和分析是移动应用开发过程中非常重要的一环,通过对用户行为的统计和分析,开发者可以深入了解用户的喜好和使用习惯,从而优化产品设计和用户体验。本文将介绍如何在uniapp中实现数据统计和分析的功能,并提供一些具体的代码示例。二、选择合适的数据统计和分析工具在uniapp中实现数据统计和分析的第一步是选择合

如何使用SQL语句在MySQL中进行数据聚合和统计?如何使用SQL语句在MySQL中进行数据聚合和统计?Dec 17, 2023 am 08:41 AM

如何使用SQL语句在MySQL中进行数据聚合和统计?在进行数据分析和统计时,数据聚合和统计是非常重要的步骤。MySQL作为一个功能强大的关系型数据库管理系统,提供了丰富的聚合和统计函数,可以很方便地进行数据聚合和统计操作。本文将介绍使用SQL语句在MySQL中进行数据聚合和统计的方法,并提供具体的代码示例。一、使用COUNT函数进行计数COUNT函数是最常用

在Beego中使用Google Analytics统计网站数据在Beego中使用Google Analytics统计网站数据Jun 22, 2023 am 09:19 AM

随着互联网的快速发展,Web应用程序的使用越来越普遍,如何对Web应用程序的使用情况进行监控和分析成为了开发者和网站经营者的关注点。GoogleAnalytics是一种强大的网站分析工具,可以对网站访问者的行为进行跟踪和分析。本文将介绍如何在Beego中使用GoogleAnalytics来统计网站数据。一、注册GoogleAnalytics账号首先需要

源码探秘:Python 中对象是如何被调用的?源码探秘:Python 中对象是如何被调用的?May 11, 2023 am 11:46 AM

楔子我们知道对象被创建,主要有两种方式,一种是通过Python/CAPI,另一种是通过调用类型对象。对于内置类型的实例对象而言,这两种方式都是支持的,比如列表,我们即可以通过[]创建,也可以通过list(),前者是Python/CAPI,后者是调用类型对象。但对于自定义类的实例对象而言,我们只能通过调用类型对象的方式来创建。而一个对象如果可以被调用,那么这个对象就是callable,否则就不是callable。而决定一个对象是不是callable,就取决于其对应的类型对象中是否定义了某个方法。如

Vue框架下,如何快速搭建统计图表系统Vue框架下,如何快速搭建统计图表系统Aug 21, 2023 pm 05:48 PM

Vue框架下,如何快速搭建统计图表系统在现代网页应用中,统计图表是必不可少的组成部分。Vue.js作为一款流行的前端框架,提供了很多便捷的工具和组件,能够帮助我们快速搭建统计图表系统。本文将介绍如何利用Vue框架以及一些插件来搭建一个简单的统计图表系统。首先,我们需要准备一个Vue.js的开发环境,包括安装Vue脚手架以及一些相关的插件。在命令行中执行以下命

Vue统计图表的线性、饼状图功能实现Vue统计图表的线性、饼状图功能实现Aug 19, 2023 pm 06:13 PM

Vue统计图表的线性、饼状图功能实现在数据分析和可视化领域,统计图表是一种非常常用的工具。Vue作为一种流行的JavaScript框架,提供了便捷的方法来实现各种功能,包括统计图表的展示和交互。本文将介绍如何使用Vue来实现线性和饼状图功能,并提供相应的代码示例。线性图功能实现线性图是一种用于展示数据趋势和变化的图表类型。在Vue中,我们可以使用一些优秀的第

如何使用MySQL的COUNT函数统计数据表的行数如何使用MySQL的COUNT函数统计数据表的行数Jul 25, 2023 pm 02:09 PM

如何使用MySQL的COUNT函数统计数据表的行数在MySQL中,COUNT函数是一个非常强大的函数,用于统计数据表中满足特定条件的行数。本文将介绍如何使用MySQL的COUNT函数来统计数据表的行数,并提供相关的代码示例。COUNT函数的语法如下:SELECTCOUNT(column_name)FROMtable_nameWHEREconditi

统计分析法的步骤统计分析法的步骤Jun 28, 2023 pm 03:27 PM

统计分析,常指对收集到的有关数据资料进行整理归类并进行解释的过程。统计分析的基本步骤包括:1、收集数据;2、整理数据;3、分析数据。

See all articles

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 agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools