pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedPostgres 9 : - How to interpret the EXPLAIN query results
8+ messages / 5 participants
[nested] [flat]
* Postgres 9 : - How to interpret the EXPLAIN query results
@ 2015-03-25 08:00 Khangelani Gama <kgama@argility.com>
2015-03-25 09:33 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Anthony Nowocien <anowocien@gmail.com>
2015-03-25 10:04 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Raghavendra <raghavendra.rao@enterprisedb.com>
2015-03-26 03:00 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Venkata Balaji N <nag1010@gmail.com>
0 siblings, 3 replies; 8+ messages in thread
From: Khangelani Gama @ 2015-03-25 08:00 UTC (permalink / raw)
To: pgsql-admin
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.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
@ 2015-03-25 09:33 ` Anthony Nowocien <anowocien@gmail.com>
2 siblings, 0 replies; 8+ messages in thread
From: Anthony Nowocien @ 2015-03-25 09:33 UTC (permalink / raw)
To: Khangelani Gama <kgama@argility.com>; +Cc: pgsql-admin
Hi,
everything you need to know is available on the documentation at
http://www.postgresql.org/docs/current/static/sql-explain.html.
*"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
On Wed, Mar 25, 2015 at 9:00 AM, 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)
>
>
>
>
>
>
>
>
>
>
> 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.
>
>
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
@ 2015-03-25 10:04 ` Raghavendra <raghavendra.rao@enterprisedb.com>
2015-03-25 10:28 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2 siblings, 1 reply; 8+ messages in thread
From: Raghavendra @ 2015-03-25 10:04 UTC (permalink / raw)
To: Khangelani Gama <kgama@argility.com>; +Cc: pgsql-admin
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.
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)
http://www.postgresql.org/docs/9.3/static/sql-explain.html
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
>
>
>
>
>
>
>
>
> 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.
>
>
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-25 10:04 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Raghavendra <raghavendra.rao@enterprisedb.com>
@ 2015-03-25 10:28 ` Khangelani Gama <kgama@argility.com>
2015-03-25 11:05 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Thomas Kellerer <spam_eater@gmx.net>
0 siblings, 1 reply; 8+ messages in thread
From: Khangelani Gama @ 2015-03-25 10:28 UTC (permalink / raw)
To: Raghavendra <raghavendra.rao@enterprisedb.com>; +Cc: pgsql-admin
*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)
http://www.postgresql.org/docs/9.3/static/sql-explain.html
---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/
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.
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.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-25 10:04 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Raghavendra <raghavendra.rao@enterprisedb.com>
2015-03-25 10:28 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
@ 2015-03-25 11:05 ` Thomas Kellerer <spam_eater@gmx.net>
2015-03-25 11:34 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Kellerer @ 2015-03-25 11:05 UTC (permalink / raw)
To: pgsql-admin
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
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-25 10:04 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Raghavendra <raghavendra.rao@enterprisedb.com>
2015-03-25 10:28 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-25 11:05 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Thomas Kellerer <spam_eater@gmx.net>
@ 2015-03-25 11:34 ` Khangelani Gama <kgama@argility.com>
0 siblings, 0 replies; 8+ messages in thread
From: Khangelani Gama @ 2015-03-25 11:34 UTC (permalink / raw)
To: Thomas Kellerer <spam_eater@gmx.net>; pgsql-admin
-----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.
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
@ 2015-03-26 03:00 ` Venkata Balaji N <nag1010@gmail.com>
2015-03-26 04:22 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2 siblings, 1 reply; 8+ messages in thread
From: Venkata Balaji N @ 2015-03-26 03:00 UTC (permalink / raw)
To: Khangelani Gama <kgama@argility.com>; +Cc: pgsql-admin
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
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Postgres 9 : - How to interpret the EXPLAIN query results
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-26 03:00 ` Re: Postgres 9 : - How to interpret the EXPLAIN query results Venkata Balaji N <nag1010@gmail.com>
@ 2015-03-26 04:22 ` Khangelani Gama <kgama@argility.com>
0 siblings, 0 replies; 8+ messages in thread
From: Khangelani Gama @ 2015-03-26 04:22 UTC (permalink / raw)
To: Venkata Balaji N <nag1010@gmail.com>; +Cc: pgsql-admin
*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.
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2015-03-26 04:22 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 08:00 Postgres 9 : - How to interpret the EXPLAIN query results Khangelani Gama <kgama@argility.com>
2015-03-25 09:33 ` Anthony Nowocien <anowocien@gmail.com>
2015-03-25 10:04 ` Raghavendra <raghavendra.rao@enterprisedb.com>
2015-03-25 10:28 ` Khangelani Gama <kgama@argility.com>
2015-03-25 11:05 ` Thomas Kellerer <spam_eater@gmx.net>
2015-03-25 11:34 ` Khangelani Gama <kgama@argility.com>
2015-03-26 03:00 ` Venkata Balaji N <nag1010@gmail.com>
2015-03-26 04:22 ` Khangelani Gama <kgama@argility.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox