[asterisk-dev] Optimize CDR batch mode

C.Maj chris at PenguinPBX.com
Tue Jun 16 11:26:07 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 ?

> 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.


Regards,

-- 
🤠 C. Maj, Technology Captain @ Penguin PBX Solutions
📞 USA Toll Free 1-833-PNGNPBX (1-833-764-6729)
🤙 International & SMS Texting +1.720.32.42.72.9
🐧 Visit on the World Wide Web at PENGUINPBX.COM



More information about the asterisk-dev mailing list