When records in table orbeon_form_data grow to 2600+ rows, we started to experience slow response for Persistent API /search/$app/$form
, it took 24000+ ms to return result.
Search API and the example of POST BODY as below: http://localhost/orbeon/fr/service/persistence/search/MYAPP/MYFORM
<search>
<query search-field="true" match="exact" path="section-search/myKey">myValue</query>
<page-size>10</page-size>
<page-number>1</page-number>
<lang>en</lang>
</search>
We're using PostgreSQL and by comparing official postgresql-2016_2.sql
with oracle-2016_2.sql
, the Oracle version contains extra statement to create indexes.
Could the missing index the reason of the slow response?
Below is the partial log:
2016-09-30 14:22:58,846 INFO ProcessorService - /fr/service/persistence/form/MYAPP/MYFORM - Timing: 64
2016-09-30 14:22:58,846 INFO lifecycle - event: {"request": "5624", "session": "FBBA97DDA0A35BA878C01250536E791F", "source": "service", "message": "end: handle", "time": "64 ms"}
2016-09-30 14:23:23,443 INFO ProcessorService - /fr/service/postgresql/search/MYAPP/MYFORM - Timing: 24670
2016-09-30 14:23:23,444 INFO lifecycle - event: {"request": "5623", "session": "FBBA97DDA0A35BA878C01250536E791F", "source": "service", "message": "end: handle", "time": "24,671 ms"}
SELECT COUNT(*)
FROM (SELECT c.data_id,
c.document_id,
c.draft,
c.created,
c.last_modified_time,
c.last_modified_by,
c.username,
c.groupname,
ROW_NUMBER() OVER (ORDER BY c.last_modified_time DESC) ROW_NUMBER
FROM orbeon_i_current c,
orbeon_form_data d
WHERE c.app = 'MYAPP'
AND c.form = 'MYFORM'
AND c.draft = 'N'
AND d.id = c.data_id
AND xml::text ilike ?) a;
SELECT c.*,
t.control,
t.pos,
t.val
FROM (SELECT c.data_id,
c.document_id,
c.draft,
c.created,
c.last_modified_time,
c.last_modified_by,
c.username,
c.groupname,
ROW_NUMBER() OVER (ORDER BY c.last_modified_time DESC) ROW_NUMBER
FROM orbeon_i_current c,
orbeon_form_data d
WHERE c.app = 'MYAPP'
AND c.form = 'MYFORM'
AND c.draft = 'N'
AND d.id = c.data_id
AND xml::text ilike ?) c
LEFT JOIN orbeon_i_control_text t ON c.data_id = t.data_id
WHERE ROW_NUMBER BETWEEN 1 AND 10 ;