Обсуждение: Postgres 9 : - How to interpret the EXPLAIN query results
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
"COSTS
Include information on the estimated startup and total cost of each plan node, as well as the estimated number of rows and the estimated width of each row. This parameter defaults to TRUE."
- Best regards,
- Anthony
- Anthony
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
From: Raghavendra [mailto:raghavendra.rao@enterprisedb.com]
Sent: 25 March 2015 12:04 PM
To: Khangelani Gama
Cc: pgsql-admin
Subject: Re: [ADMIN] Postgres 9 : - How to interpret the EXPLAIN query results
On Wed, Mar 25, 2015 at 1:30 PM, Khangelani Gama <kgama@argility.com> wrote:
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
Its like ..
NodeType (cost=startup-cost..total-cost rows=plan rows width=bytes per-row)
Documentation has briefed well on the explain output. Here's example.
Thanks to all, but if this total cost is the total time it will take to retrieve the output then is it in minutes or milliseconds? If it’s in milliseconds does it mean that it take about 213 hrs for a total of 768375132.77
postgres=# explain select * from foo;
QUERY PLAN
-----------------------------------------------------------
Seq Scan on foo (cost=0.00..5770.01 rows=400001 width=4)
(1 row)
postgres=# EXPLAIN (FORMAT JSON) SELECT * FROM foo;
QUERY PLAN
--------------------------------
[ +
{ +
"Plan": { +
"Node Type": "Seq Scan",+
"Relation Name": "foo", +
"Alias": "foo", +
"Startup Cost": 0.00, +
"Total Cost": 5770.01, +
"Plan Rows": 400001, +
"Plan Width": 4 +
} +
} +
]
(1 row)
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
CONFIDENTIALITY NOTICEThe contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidentialinformation of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyoneother than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediatelyand destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liabilityfor unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
Khangelani Gama schrieb am 25.03.2015 um 11:28: > Thanks to all, but if this total cost is the total time it will take to retrieve the output then is it in minutes or milliseconds? > If it’s in milliseconds does it mean that it take about 213 hrs for a total of 768375132.77 No. The cost is not the total time. Quote from the manual measured in cost units that are arbitrary, but conventionally mean disk page fetches In general you can _assume_ that a query with a higher cost is likely to run longer than an equivalent query with lower costs. If you want the runtime of each step you need to use "explain (analyze)" - again this is documented in the manual. Thomas
-----Original Message----- From: pgsql-admin-owner@postgresql.org [mailto:pgsql-admin-owner@postgresql.org] On Behalf Of Thomas Kellerer Sent: 25 March 2015 01:05 PM To: pgsql-admin@postgresql.org Subject: Re: [ADMIN] Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama schrieb am 25.03.2015 um 11:28: > Thanks to all, but if this total cost is the total time it will take to > retrieve the output then is it in minutes or milliseconds? > If it’s in milliseconds does it mean that it take about 213 hrs for a > total of 768375132.77 No. The cost is not the total time. Quote from the manual measured in cost units that are arbitrary, but conventionally mean disk page fetches In general you can _assume_ that a query with a higher cost is likely to run longer than an equivalent query with lower costs. If you want the runtime of each step you need to use "explain (analyze)" - again this is documented in the manual. Thomas Many Thanks Thomas -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
GroupAggregate (cost=xxxx.xx..yyyyy.yy rows=xxxnx width=xx) (actual time=(actual time=xxx.xx rows=xx loops=x)
From: Venkata Balaji N [mailto:nag1010@gmail.com]
Sent: 26 March 2015 05:00 AM
To: Khangelani Gama
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Postgres 9 : - How to interpret the EXPLAIN query results
On Wed, Mar 25, 2015 at 7:00 PM, Khangelani Gama <kgama@argility.com> wrote:
Hi
Please help, how can I interpret the following results of my EXPLAIN query ?, I can see that the query will through 18586018 rows, but what’s the meaning of cost and width?
GroupAggregate (cost=762381141.96..768375132.77 rows=18586018 width=32)
cost=762381141.96..768375132.77 means, cost of retrieving the first row is 762381141.96 and the cost of retrieving all the rows is 768375132.77.
rows=18586018 means, expected number of rows as an output.
width=32 means, width of each row scanned/retrieved is 32 bytes.
Cost calculation formula for PostgreSQL is as follows :
cost = (disk pages read * seq_page_cost) + (rows scanned * cpu_tuple_cost)
The above formula may help you analyze/reduce the cost of the query.
If you do an EXPLAIN ANALYZE (sample output is below), that will further help you get more information like query completion time in milli-seconds (actual time), number of rows returned (rows) and how many iterations the query went through to get the output (loop)
GroupAggregate (cost=xxxx.xx..yyyyy.yy rows=xxxnx width=xx) (actual time=(actual time=xxx.xx rows=xx loops=x)
Thanks,
Venkata Balaji N
Thank you very much !!
CONFIDENTIALITY NOTICE The contents of and attachments to this e-mail are intended for the addressee only, and may contain the confidential information of Argility (Proprietary) Limited and/or its subsidiaries. Any review, use or dissemination thereof by anyone other than the intended addressee is prohibited.If you are not the intended addressee please notify the writer immediately and destroy the e-mail. Argility (Proprietary) Limited and its subsidiaries distance themselves from and accept no liability for unauthorised use of their e-mail facilities or e-mails sent other than strictly for business purposes.