[asterisk-dev] Optimize CDR batch mode

Gabriel Ortiz Lour ortiz.admin at gmail.com
Tue Jun 16 23:29:32 CDT 2020


>
> On 2020-06-15 22:21, Gabriel Ortiz Lour wrote:
> > single COPY sql command, which is much faster than single INSERTs
>
> I agree with COPY on large data sets but how many CDRs are you INSERT
> batching and at what intervals ?
>
batch=yes
size=1000
time=10
on my test machine I was with this values, and sometimes it would reach the
10s, sometimes flush because of the 1000 cdrs

>
> > Sounds like a small addition for having a much faster CDR insertion
>
> I think there are several trade-offs w/r/t PostgreSQL COPY vs. INSERT...
>
> 1. COPY FROM "file" is not (as easily) available if PostgreSQL and
> Asterisk are running on separate servers.
>    COPY FROM STDIN is probably the better choice.
>
> 2. COPY stops on first bad record.
>
> 3. COPY disregards table RULEs created using the CREATE RULE PostgreSQL
> language extension.
>    eg. it 'breaks' things like "CREATE RULE rule_insert_cdr ON INSERT TO
> cdr ..." since that only works on INSERT not COPY.
>
> So, maybe give the user a choice, with a new option in cdr.conf and/or
> cdr_pgsql.conf:
>
>         cdr_batch_prefer_op=insert      ; Default is 'insert'.
>                                         ; Other choice includes 'copy'.
>                                         ; Falls back to 'insert' if 'copy'
> fails.
>                                         ; Only available on certain
> backends eg. PostgreSQL.
>
 right, would do
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20200617/2a887f28/attachment.html>


More information about the asterisk-dev mailing list