Re: Postgres 9 : - How to interpret the EXPLAIN query results

From: Venkata Balaji N <nag1010(at)gmail(dot)com>
To: Khangelani Gama <kgama(at)argility(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Postgres 9 : - How to interpret the EXPLAIN query results
Date: 2015-03-26 03:00:11
Message-ID: CAEyp7J-DgHgAj2tVQ7O9hg7zKVwLLPRGzYbozDxv8vuG0qENrw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Mar 25, 2015 at 7:00 PM, Khangelani Gama <kgama(at)argility(dot)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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Khangelani Gama 2015-03-26 04:22:42 Re: Postgres 9 : - How to interpret the EXPLAIN query results
Previous Message naveen kumar 2015-03-25 23:57:32 Re: ERROR: functions in index expression must be marked IMMUTABLE