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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Wed, Mar 25, 2015 at 7:00 PM, Khangelani Gama <kgama@xxxxxxxxxxxx> 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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux