<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Greenplum DBA Script &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/category/greenplum-dba-script/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Fri, 22 Sep 2017 20:48:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>Greenplum: Script to find running queries or statements which are Waiting in Resource Queues</title>
		<link>https://www.dbrnd.com/2017/11/greenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 30 Nov 2017 16:16:09 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_resqueue_status]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Resource Queue]]></category>
		<category><![CDATA[Workload management]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6120</guid>

					<description><![CDATA[In this post, I am sharing a script to check the list of running queries or statements which are waiting in the Resource Queues of Greenplum. The Workload management of Greenplum means &#8211; Set priorities of database user&#8217;s queries using Resource Queues. If you create RQ with the limit of 10 concurrent queries and user [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues%2F&#038;title=Greenplum%3A%20Script%20to%20find%20running%20queries%20or%20statements%20which%20are%20Waiting%20in%20Resource%20Queues" data-a2a-url="https://www.dbrnd.com/2017/11/greenplum-script-to-find-running-queries-or-statements-which-are-waiting-in-resource-queues/" data-a2a-title="Greenplum: Script to find running queries or statements which are Waiting in Resource Queues"></a></p><p>In this post, I am sharing a script to check the list of running queries or statements which are waiting in the Resource Queues of Greenplum. </p>
<blockquote><p>The Workload management of Greenplum means &#8211; Set priorities of database user&#8217;s queries using Resource Queues. If you create RQ with the limit of 10 concurrent queries and user is trying to execute more than 10 queries at a time then few RQ keeps few queries in the waiting mode. </p></blockquote>
<p>Using below query, you can get the list of running queries which are in the waiting mode.</p>
<pre class="crayon-plain-tag">SELECT
	rolname
	,rsqname
	,pid
	,granted
	,current_query
	,datname
FROM pg_roles, gp_toolkit.gp_resqueue_status
,pg_locks, pg_stat_activity
WHERE pg_roles.rolresqueue=pg_locks.objid
	AND pg_locks.objid=gp_toolkit.gp_resqueue_status.queueid
	AND pg_stat_activity.procpid=pg_locks.pid
	AND pg_stat_activity.usename=pg_roles.rolnam</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to find information for Long running Queries with occupied resource</title>
		<link>https://www.dbrnd.com/2017/11/greenplum-script-to-find-information-for-long-running-queries-with-occupied-resource/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 26 Nov 2017 16:16:39 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[GPCC]]></category>
		<category><![CDATA[GPPERFMON]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[queries_history]]></category>
		<category><![CDATA[system_history]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6139</guid>

					<description><![CDATA[In this post, I am sharing a script to find the average running time and average resource utilization of running queries in Greenplum. I am using the table of GPCC which are available in GPPERFMON database. So if you don&#8217;t configure GPCC, you can&#8217;t use below query. Using below query, you can find the total [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-find-information-for-long-running-queries-with-occupied-resource%2F&#038;title=Greenplum%3A%20Script%20to%20find%20information%20for%20Long%20running%20Queries%20with%20occupied%20resource" data-a2a-url="https://www.dbrnd.com/2017/11/greenplum-script-to-find-information-for-long-running-queries-with-occupied-resource/" data-a2a-title="Greenplum: Script to find information for Long running Queries with occupied resource"></a></p><p>In this post, I am sharing a script to find the average running time and average resource utilization of running queries in Greenplum. </p>
<p>I am using the table of GPCC which are available in GPPERFMON database. So if you don&#8217;t configure GPCC, you can&#8217;t use below query. </p>
<p>Using below query, you can find the total average run time, average CPU, average Memory occupied by long-running queries which took more than 20 minutes and checking for only last 10 days.<br />
As per your requirement, you can change the minutes and days filter value. </p>
<pre class="crayon-plain-tag">select
	sh.ctime
	,query_text
	,username
	,db as DatabaseName
	,rsqname as ResourceQueueName
	,avg(tfinish-tstart) as AverageRunTime
	,count(*) as TotalExecution
	,round(avg(100 - cpu_idle)::numeric,2) as AverageCPUUsed
	,round(max(100 - cpu_idle)::numeric,2) as MaxCPUUsed
	,round(avg(mem_actual_used)/power(1024,3)::numeric,2) as AverageMemoryUsed
	,round(max(mem_actual_used)/power(1024,3)::numeric,2) as MaxMemoryUsed
from system_history sh, queries_history qh
where sh.ctime between date_trunc('day',localtimestamp - interval '10 days')
	and date_trunc('day',localtimestamp)
	and sh.ctime=qh.ctime
	and db not in ('gpperfmon')
	and date_part('hour',tfinish - tstart)*60 + date_part('minute',tfinish - tstart) &gt; 20
group by sh.ctime,query_text,username, db,rsqname;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to check the size of Database, Schema and Table (Using gp_toolkit schema)</title>
		<link>https://www.dbrnd.com/2017/11/greenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 18 Nov 2017 16:16:33 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_size_of_database]]></category>
		<category><![CDATA[gp_size_of_schema_disk]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[pg_size_pretty]]></category>
		<category><![CDATA[pg_total_relation_size]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[schema]]></category>
		<category><![CDATA[Table]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6118</guid>

					<description><![CDATA[In this post, I am sharing a few scripts for checking the size of Database, Schema and Table of Greenplum Server. Here, I am doing this exercise using the views of the gp_toolkit schema of Greenplum. Check the size of database in MB, GB and TB: [crayon-6ab44fac68f35226501142/] Checkt the size of database in MB, GB [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F11%2Fgreenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema%2F&#038;title=Greenplum%3A%20Script%20to%20check%20the%20size%20of%20Database%2C%20Schema%20and%20Table%20%28Using%20gp_toolkit%20schema%29" data-a2a-url="https://www.dbrnd.com/2017/11/greenplum-script-to-check-the-size-of-database-schema-and-table-using-gp_toolkit-schema/" data-a2a-title="Greenplum: Script to check the size of Database, Schema and Table (Using gp_toolkit schema)"></a></p><p>In this post, I am sharing a few scripts for checking the size of Database, Schema and Table of Greenplum Server. </p>
<p>Here, I am doing this exercise using the views of the gp_toolkit schema of Greenplum. </p>
<p><strong>Check the size of database in MB, GB and TB:</strong></p>
<pre class="crayon-plain-tag">SELECT sodddatname, (sodddatsize/1048576) AS Sizein_MB
FROM gp_toolkit.gp_size_of_database;
 
SELECT sodddatname, (sodddatsize/1073741824) AS Sizein_GB
FROM gp_toolkit.gp_size_of_database;
 
SELECT sodddatname, (sodddatsize/1073741824)/1024 AS Sizein_TB
FROM gp_toolkit.gp_size_of_database;</pre> </p>
<p><strong>Checkt the size of database in MB, GB and TB:</strong></p>
<pre class="crayon-plain-tag">SELECT sosdnsp, (sosdschematablesize/1048576) AS Sizein_MB
FROM gp_toolkit.gp_size_of_schema_disk;
 
SELECT sosdnsp, (sosdschematablesize/1073741824) AS Sizein_GB
FROM gp_toolkit.gp_size_of_schema_disk;
 
SELECT sosdnsp, (sosdschematablesize/1073741824)/1024 AS Sizein_TB
FROM gp_toolkit.gp_size_of_schema_disk;</pre> </p>
<p><strong>Check the size of any Table or Index:</strong></p>
<pre class="crayon-plain-tag">SELECT pg_size_pretty(pg_total_relation_size('schema_name.table_name'));</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to check Tablespace and Filespace information</title>
		<link>https://www.dbrnd.com/2017/07/greenplum-script-to-check-tablespace-and-filespace-information/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 28 Jul 2017 16:16:08 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[pg_tablespace]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Tablespace]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5713</guid>

					<description><![CDATA[In this post, I am sharing a script to check the Tablespace and Filespace information in Greenplum. In a big database system, DBAs are creating different tablespaces for storage purpose so using below script we can get the information of tablespaces. [crayon-6ab44fac68fd4039204103/]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-tablespace-and-filespace-information%2F&#038;title=Greenplum%3A%20Script%20to%20check%20Tablespace%20and%20Filespace%20information" data-a2a-url="https://www.dbrnd.com/2017/07/greenplum-script-to-check-tablespace-and-filespace-information/" data-a2a-title="Greenplum: Script to check Tablespace and Filespace information"></a></p><p>In this post, I am sharing a script to check the Tablespace and Filespace information in Greenplum.</p>
<p>In a big database system, DBAs are creating different tablespaces for storage purpose so using below script we can get the information of tablespaces.</p>
<pre class="crayon-plain-tag">SELECT
	spcname as tblspc
	,fsname as filespc
	,fsedbid as seg_dbid
	,fselocation as datadir
FROM pg_tablespace pgts
	,pg_filespace pgfs
	,pg_filespace_entry pgfse
WHERE pgts.spcfsoid=pgfse.fsefsoid
AND pgfse.fsefsoid=pgfs.oid
ORDER BY tblspc, seg_dbid</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to check the full disk space of DCA</title>
		<link>https://www.dbrnd.com/2017/07/greenplum-script-to-check-the-full-disk-space-of-dca/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 16:16:28 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[DCA]]></category>
		<category><![CDATA[diskspace_now]]></category>
		<category><![CDATA[gp_disk_free]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5705</guid>

					<description><![CDATA[In this post, I am sharing two different scripts to check the full size of Greenplum DCA. To monitor the disk space is a ubiquitous task of DBA. DBA can use below script and can automate the report on disk size notification/alert. There are different options to check the disk size of the server; below [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&amp;linkname=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-check-the-full-disk-space-of-dca%2F&#038;title=Greenplum%3A%20Script%20to%20check%20the%20full%20disk%20space%20of%20DCA" data-a2a-url="https://www.dbrnd.com/2017/07/greenplum-script-to-check-the-full-disk-space-of-dca/" data-a2a-title="Greenplum: Script to check the full disk space of DCA"></a></p><p>In this post, I am sharing two different scripts to check the full size of Greenplum DCA.<br />
To monitor the disk space is a ubiquitous task of DBA. DBA can use below script and can automate the report on disk size notification/alert.</p>
<p>There are different options to check the disk size of the server; below I prepared two queries using gpperfmon database and gp_toolkit schema.</p>
<p><strong>Use gpperfmon Database:</strong></p>
<pre class="crayon-plain-tag">select
	hostname
	,filesystem
	,round(total_bytes/power(1024,4)::numeric,2) as TotalSize_inTB
	,round(bytes_used/power(1024,4)::numeric,2) as UsedSize_inTB
	,round(bytes_available/power(1024,4)::numeric,2) as AvailableSize_inTB
from diskspace_now
where filesystem in ('/data1','/data2')
ORDER BY 4 DESC</pre> </p>
<p><strong>Use gp_toolkit Schema:</strong></p>
<pre class="crayon-plain-tag">select
	distinct dfhostname
	,dfdevice
	,dfspace
from gp_toolkit.gp_disk_free</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to find a list of DISTRIBUTED RANDOMLY Table</title>
		<link>https://www.dbrnd.com/2017/07/greenplum-script-to-find-a-list-of-distributed-randomly-table/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 09 Jul 2017 16:16:35 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Distributed Randomly]]></category>
		<category><![CDATA[distribution key]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5590</guid>

					<description><![CDATA[As Greenplum is a MPP architecture, so distribution of data in all segments is the first stuff. You can distribute your table data using Distributed BY , and if you are not sure about a particular column, you can create your table using Distributed Randomly. But tables which are distributed randomly, are not good for [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-a-list-of-distributed-randomly-table%2F&#038;title=Greenplum%3A%20Script%20to%20find%20a%20list%20of%20DISTRIBUTED%20RANDOMLY%20Table" data-a2a-url="https://www.dbrnd.com/2017/07/greenplum-script-to-find-a-list-of-distributed-randomly-table/" data-a2a-title="Greenplum: Script to find a list of DISTRIBUTED RANDOMLY Table"></a></p><p>As Greenplum is a MPP architecture, so distribution of data in all segments is the first stuff.</p>
<blockquote><p>You can distribute your table data using Distributed BY <ID>, and if you are not sure about a particular column, you can create your table using Distributed Randomly.</p></blockquote>
<p>But tables which are distributed randomly, are not good for table performance because query optimizer will take more time for Randomly distributed tables.<br />
Greenplum DBA can use below script to find randomly distributed tables.</p>
<pre class="crayon-plain-tag">with cte AS
(
	SELECT                 
		pgn.nspname as SchemaName                 
		,pgc.relname as TableName
		,pga.attname as DistributionType
	FROM
	(
		SELECT gdp.localoid,
			CASE
			WHEN ( Array_upper(gdp.attrnums, 1) &gt; 0 ) THEN
			Unnest(gdp.attrnums)
			ELSE NULL
			END AS attnum
		FROM gp_distribution_policy gdp
		ORDER BY gdp.localoid
	) AS distrokey
	INNER JOIN pg_class AS pgc
		ON distrokey.localoid = pgc.oid
	INNER JOIN pg_namespace pgn
		ON pgc.relnamespace = pgn.oid
	LEFT OUTER JOIN pg_attribute pga
		ON distrokey.attnum = pga.attnum
	AND distrokey.localoid = pga.attrelid      
)
select
	SchemaName
	,TableName      
	,COALESCE(DistributionType,'DISTRIBUTED RANDOMLY') AS DistributionType
from cte
where COALESCE(DistributionType,'DISTRIBUTED RANDOMLY')='DISTRIBUTED RANDOMLY'
ORDER BY SchemaName,TableName</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to find list of Append Only or Append Optimized Tables</title>
		<link>https://www.dbrnd.com/2017/07/greenplum-script-to-find-list-of-append-only-or-append-optimized-tables/</link>
					<comments>https://www.dbrnd.com/2017/07/greenplum-script-to-find-list-of-append-only-or-append-optimized-tables/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Thu, 06 Jul 2017 16:16:50 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[Append Only]]></category>
		<category><![CDATA[Append Optimized]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5577</guid>

					<description><![CDATA[In this post, I am sharing a script to find a list of Append Only or Append Optimized tables of Greenplum. Before Greenplum 4.3, when you create Append only table, you can only perform insert and select on that table. But from Greenplum 4.3, now you can perform UPDATE as well but still Append Only [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-list-of-append-only-or-append-optimized-tables%2F&#038;title=Greenplum%3A%20Script%20to%20find%20list%20of%20Append%20Only%20or%20Append%20Optimized%20Tables" data-a2a-url="https://www.dbrnd.com/2017/07/greenplum-script-to-find-list-of-append-only-or-append-optimized-tables/" data-a2a-title="Greenplum: Script to find list of Append Only or Append Optimized Tables"></a></p><p>In this post, I am sharing a script to find a list of Append Only or Append Optimized tables of Greenplum.</p>
<blockquote><p>Before Greenplum 4.3, when you create Append only table, you can only perform insert and select on that table.<br />
But from Greenplum 4.3, now you can perform UPDATE as well but still Append Only is efficient storage.</p></blockquote>
<p>The Append Only tables are faster and also it reduces the disk usage by compressing the data size. You can use below script to find a list of Append only tables.</p>
<pre class="crayon-plain-tag">SELECT   
	b.nspname||'.'||a.relname as TableName
	,case c.columnstore
		when 'f' then 'Row Orientation'        
		when 't' then 'Column Orientation'
	end as TableStorageType
	,case COALESCE(c.compresstype,'')
		when '' then 'No Compression'        
		else c.compresstype
	end as CompressionType
FROM pg_class a
,pg_namespace b
,(select relid,segrelid,segidxid,columnstore,compresstype from pg_appendonly) c
WHERE b.oid=a.relnamespace
	and a.oid=c.relid</pre> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/07/greenplum-script-to-find-list-of-append-only-or-append-optimized-tables/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Greenplum: Script to find the usage of Work spill file per Running Query</title>
		<link>https://www.dbrnd.com/2017/07/greenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 01 Jul 2017 16:16:04 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[gp_workfile_usage_per_query]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Work Spill file]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5445</guid>

					<description><![CDATA[In this post, I am sharing a script to find the total usage of work spill files for each running query in Greenplum. Whenever we are doing hash aggregation operation like GROUP BY or DISTINCT on billions of data, query executor holds this data in temporary files which called work spill files. We should optimize [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F07%2Fgreenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query%2F&#038;title=Greenplum%3A%20Script%20to%20find%20the%20usage%20of%20Work%20spill%20file%20per%20Running%20Query" data-a2a-url="https://www.dbrnd.com/2017/07/greenplum-script-to-find-the-usage-of-work-spill-file-per-running-query-gp_toolkit-gp_workfile_usage_per_query/" data-a2a-title="Greenplum: Script to find the usage of Work spill file per Running Query"></a></p><p>In this post, I am sharing a script to find the total usage of work spill files for each running query in Greenplum.</p>
<blockquote><p>Whenever we are doing hash aggregation operation like GROUP BY or DISTINCT on billions of data, query executor holds this data in temporary files which called work spill files.</p></blockquote>
<p>We should optimize our query to reduce the maximum use of work spill files because it degrades the overall performance and also requires more disk space.</p>
<p>Using below script, we can monitor the usage of work spill file for each running query and we can also optimize the long running queries.</p>
<pre class="crayon-plain-tag">SELECT
	gwupq.datname
	,psa.usename
	,gwupq.procpid
	,gwupq.sess_id
	,sum(gwupq.size)/1024::float as total_spill_size_kb
	,sum(gwupq.numfiles) as total_spill_file
FROM  gp_toolkit.gp_workfile_usage_per_query as gwupq
inner join pg_stat_activity psa
	on gwupq.procpid = psa.procpid
	and gwupq.sess_id = psa.sess_id
GROUP BY 1,2,3,4;</pre> </p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: How to find Skewness of table (Skew of data)?</title>
		<link>https://www.dbrnd.com/2017/06/greenplum-how-to-find-skewness-of-table-skew-of-data/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 30 Jun 2017 16:16:43 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Skew of data)]]></category>
		<category><![CDATA[Skewness]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5443</guid>

					<description><![CDATA[The Greenplum is a based on MPP (Massive Parallel Processing) architecture. There are multiple segments running in nothing shared mode that means your data should equally distribute across all segments. If table data is not equally distributed, we cannot achieve the good performance of parallel processing system. The Skewness of the table means that table [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&amp;linkname=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-how-to-find-skewness-of-table-skew-of-data%2F&#038;title=Greenplum%3A%20How%20to%20find%20Skewness%20of%20table%20%28Skew%20of%20data%29%3F" data-a2a-url="https://www.dbrnd.com/2017/06/greenplum-how-to-find-skewness-of-table-skew-of-data/" data-a2a-title="Greenplum: How to find Skewness of table (Skew of data)?"></a></p><p>The Greenplum is a based on MPP (Massive Parallel Processing) architecture.<br />
There are multiple segments running in nothing shared mode that means your data should equally distribute across all segments.</p>
<p>If table data is not equally distributed, we cannot achieve the good performance of parallel processing system. </p>
<blockquote><p>The Skewness of the table means that table data is not equally distributed across the segments and workload is not divided properly between the segments.</p></blockquote>
<p>You can find skewness of data by checking gp_segment_id for each record.</p>
<blockquote><p>The record count of segments should be very near to each other like 90% to 95%, and if you find a big difference in a count or 0 counts for few segments that mean your data is not properly distributed.</p></blockquote>
<pre class="crayon-plain-tag">SELECT gp_segment_id, count(*)
FROM table_name
GROUP BY gp_segment_id;</pre> </p>
<p><strong>Other two gp_toolkit views to get the information of Skewness of data:</strong></p>
<p><strong>gp_toolkit.gp_skew_coefficients:</strong> This view shows data distribution skew by calculating the coefficient of variation (CV) for the data stored on each segment.<br />
<strong>gp_toolkit.gp_skew_idle_fractions:</strong> This view shows data distribution skew by calculating the percentage of the system that is idle during a table scan, which is an indicator of processing data skew.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Greenplum: Script to find Work Spill Files usage for all Segments</title>
		<link>https://www.dbrnd.com/2017/06/greenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Fri, 23 Jun 2017 16:16:16 +0000</pubDate>
				<category><![CDATA[Greenplum]]></category>
		<category><![CDATA[Greenplum DBA Script]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gp_toolkit]]></category>
		<category><![CDATA[gp_workfile_entries]]></category>
		<category><![CDATA[Greenplum Administrator]]></category>
		<category><![CDATA[Greenplum Error]]></category>
		<category><![CDATA[Greenplum Monitoring]]></category>
		<category><![CDATA[Greenplum Performance Tuning]]></category>
		<category><![CDATA[Greenplum Programming]]></category>
		<category><![CDATA[Greenplum Query]]></category>
		<category><![CDATA[Greenplum Tips and Tricks]]></category>
		<category><![CDATA[PostgreSQL 8.2]]></category>
		<category><![CDATA[Segments]]></category>
		<category><![CDATA[Work Spill file]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5439</guid>

					<description><![CDATA[In this post, I am sharing a script to find the total usage of work spill files for all the segments of Greenplum. Whenever we are doing hash aggregation operations like GROUP BY or DISTINCT on billions of data, query executor holds this data in temporary files which called work spill files. We should optimize [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&amp;linkname=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fgreenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries%2F&#038;title=Greenplum%3A%20Script%20to%20find%20Work%20Spill%20Files%20usage%20for%20all%20Segments" data-a2a-url="https://www.dbrnd.com/2017/06/greenplum-script-to-find-work-spill-files-usage-for-all-segments-gp_toolkit-gp_workfile_entries/" data-a2a-title="Greenplum: Script to find Work Spill Files usage for all Segments"></a></p><p>In this post, I am sharing a script to find the total usage of work spill files for all the segments of Greenplum.</p>
<blockquote><p>Whenever we are doing hash aggregation operations like GROUP BY or DISTINCT on billions of data, query executor holds this data in temporary files which called work spill files.</p></blockquote>
<p>We should optimize our query to reduce the maximum use of work spill files because it degrades the overall performance and also requires more disk space.<br />
Using below query, you can check the total number of spill files and their size for each segment.</p>
<pre class="crayon-plain-tag">SELECT
                gwe.datname as DatabaseName
                ,psa.usename as UserName
                ,gwe.procpid as ProcessID
                ,gwe.sess_id as SessionID
                ,sc.hostname as HostName
                ,sum(size)/1024::float as SizePerHost
                ,sum(numfiles) NumOfFilesPerHost
FROM  gp_toolkit.gp_workfile_entries as gwe
inner join pg_stat_activity as psa
                on psa.procpid = gwe.procpid
                and psa.sess_id = gwe.sess_id,
gp_segment_configuration as sc
,pg_filespace_entry as fe
,pg_database as d
WHERE fe.fsedbid=sc.dbid
                AND gwe.segid=sc.content
                AND gwe.datname=d.datname
                AND sc.role='p'
group by
                gwe.datname
                ,psa.usename
                ,gwe.procpid
                ,gwe.sess_id
                ,sc.hostname
ORDER BY
                gwe.datname
                ,psa.usename
                ,gwe.procpid
                ,gwe.sess_id
                ,sc.hostname</pre> </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
