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.