[SR-Users] MySQL query result pagination

Allen Zhang Allen.Zhang at imgtec.com
Thu Jun 5 05:54:06 CEST 2014


I found this:

SELECT column FROM table
LIMIT N OFFSET offset

Increment offset by index*N in the loop to fetch N records at a time.
But the remaining question is how do I do this using kamailio's  MySQL driver? Raw query?

Allen


From: Allen Zhang
Sent: Thursday, 5 June 2014 12:19 p.m.
To: 'sr-users at lists.sip-router.org'
Subject: MySQL query result pagination

Hi,

When an user does a REGISTER and has a large number of msilo messages stored, say 7k, kamailio server easily runs out of private memory when trying to allocate memory to the result set. I know I can set a max on the messages a user can store, but I'd like to support a crazy number like 7k messages.
I'm trying to introduce paging to the query. So that I can process N number of results at one time.
I can't find an easy way of doing this with the current MySQL driver. The db_mysql_query() function doesn't have built-in paging and with this function it's not easy to build a complex query like this:

Select * from silo where ...(the matching algorithm) AND id > lower_limit AND id < higher_limit, ordered by id.

Is there a way to do this? Or maybe I'm on the wrong track and there is already a solution to this problem?

Regards,

Allen Zhang

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20140605/06c06c14/attachment.html>


More information about the sr-users mailing list