Re: Correlating Asterisk CDRs

From: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>
To: raju(at)linux-delhi(dot)org
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Correlating Asterisk CDRs
Date: 2011-12-07 20:15:54
Message-ID: CAOR=d=2+-jRy1ZQQ5bbaL9RLdE_sS0q=bCRMKhCdoKQFpP5fLw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2011/12/7 Raj Mathur (राज माथुर) <raju(at)linux-delhi(dot)org>:
>                                                             QUERY PLAN
> ---------------------------------------------------------------------------------------------------------------------------------------------
>  Limit  (cost=46782.15..46782.40 rows=100 width=109) (actual time=4077.866..4078.054
> rows=100 loops=1)
>   ->  Sort  (cost=46782.15..46785.33 rows=1272 width=109) (actual time=4077.863..4077.926
> rows=100 loops=1)
>         Sort Key: cdr.calldate, cdr2.calldate, cdr.clid
>         Sort Method:  top-N heapsort  Memory: 42kB
>         ->  Merge Join  (cost=2.95..46733.54 rows=1272 width=109) (actual
> time=0.070..3799.546 rows=168307 loops=1)

Two things to look at here. First is that the estimation of rows
expected and returned vary by a factor over over 100, which means the
query planner may be making suboptimal choices in terms of the plan it
is running. If increasing stats target on the target columns in the
query helps, then that's worth trying. Raise it and re-analyze and
see if you get a closer estimate. To test if the merge join is the
best choice or not, you can use the set enable_xxx for it (in this
case set enable_mergejoin=off) and then run the query again through
explain analyze and see if the performance gets any better.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Vad N 2011-12-07 23:04:07 prepared statements
Previous Message Raj Mathur ( राज =?utf-8?b?IOCkruCkvuCkpeClgeCksA==?=) 2011-12-07 17:34:45 Re: Correlating Asterisk CDRs