AnsweredAssumed Answered

Inconsistent PHP speed

Question asked by submarine on Mar 21, 2014
Latest reply on Mar 26, 2014 by Vyke

I use PHP API to retrieve some data from a ODBC table in FM. A dedicated layout is created for this purpose with 8 fields, all are text or numeric fields and will be displayed on the PHP page.

The table has 4 records currently and the search will return just one record.

 

The PHP is very simple with a db connect > Find with 1 field without sort > getField > display fields.

When I run the PHP script the speed varies.

When it is first run, it takes approximately 10 sec.

I run a microtimer in PHP to check which part of the script causes the delay. It seems that the Find part is causing the delay.

Subsequently, when I re-run the script repeatedly, it generally takes less than 1/10 sec to process until the 30th+ time (see the results below). After the 30th+ delay, it's back to less than 1/10 sec until another delay at 60th+ time. This pattern keeps repeating.

At first, I thought it is the ODBC issue. I created another local table with the exact table structure and records. The result remains the same.

 

Now I suspect it is some kind of database session that PHP maintains with FM and it will expire after some short interval. The reconnection causes the delay.

Can anyone of you confirm this? If so, how can I extend the interval?

 

 

First Test

Start: 1395387977.3365
Aft dbcon: 1395387977.3551
Aft Find: 1395387987.0884 (around 10 sec)
Aft Diplay Data: 1395387987.0886

 

2nd Test

Start: 1395388000.6743
Aft dbcon: 1395388000.6881
Aft Find: 1395388000.741 (less than 0.1 sec)
Aft Diplay Data: 1395388000.7413

 

3rd Test

Start: 1395388011.9376
Aft dbcon: 1395388011.9514
Aft Find: 1395388011.9982 (less than 0.1 sec)
Aft Diplay Data: 1395388011.9985

....

 

30th+ Test

Start: 1395388045.7118
Aft dbcon: 1395388045.7254
Aft Find: 1395388055.0348 (around 10 sec)
Aft Diplay Data: 1395388055.035

 

 

Many thanks.

Outcomes