[FX.php List] Please help with slow code
Dale Bengston
dale.bengston at gmail.com
Tue Jul 1 11:57:29 MDT 2014
Hi Stephe,
Try adding
print_r($result);
after your FX query and see what’s returned.
As far as the slowdown, may we assume the sort fields are not unstored/calc fields and that you do not have any extraneous fields (especially calculation fields or portals or summary fields) on the layout referenced in your FX query.
How does it perform with just two sort fields? Just one? Any difference?
Hope this helps,
Dale
On Jul 1, 2014, at 10:15 AM, Stephe Pocock <zippyaus at yahoo.com> wrote:
> Hi Chris
>
> FX is really slow with that code. It makes no difference if I use FMPro7 or FMAlt. 16 seconds to return 200 records.
>
> The sort has not effect on FX.
>
> FAP returns the records in an blink. When the sort is added it take a second, maybe 2.
>
> I started to change my pages to FAP reluctantly, but started to compare find speeds.
>
> Using Jonathon Stark's examples, I run up a FAP page and and FX page.
>
> I am now getting some strange issues with FX.php
>
> <?php
>
> define('DEBUG', TRUE);
>
>
> require_once ('../FX/FX.php');
> $request = new FX('10.70.10.166', '80', 'FMAlt');
> $request->SetDBData('DB_Con','php_lay');
> $request->SetDBUserPass('user', 'pword');
> $request->AddSortParam('Level','ascend');
> $request->AddSortParam('Position','ascend');
> $request->AddSortParam('Name','ascend');
> $result = $request->FMFindAll();
> $records = $result['data'];
>
> echo '<table border="1">';
> echo '<tr>';
> echo '<th>Name</th>';
> echo '<th>Type</th>';
> echo '<th>Account Name</th>';
> echo '</tr>';
>
> foreach($records as $record) {
> echo '<tr>';
> echo '<td>'.$record['Name'][0].'</td>';
> echo '<td>'.$record['Position'][0].'</td>';
> echo '<td>'.$record['Level'][0].'</td>';
> echo '</tr>';
> }
> echo '</table>';
>
> ?>
>
> I have used the above code for my test. The table header row is displayed but no data. I have debugging on, and if I click the debug link, it shows all my records in the xml with an error code of 0.
>
> What is wrong with my foreach statement that would produce this result.
>
> Thank you so much
>
> Stephen
>
>
>
>
>
>
>
> From: Chris Hansen <chris at iViking.org>
> To: Stephe Pocock <zippyaus at yahoo.com>
> Cc: FX.php Discussion List <fx.php_list at mail.iviking.org>
> Sent: Monday, 30 June 2014 11:52 PM
> Subject: Re: [FX.php List] Please help with slow code
>
> Stephen,
>
> So are you saying that if you perform a query via FAP without sorting, it returns quickly? Is this the case with FX.php as well, or is it still slow? If it's the sort that is slow, and you're only dealing with a couple hundred records, I'd absolutely perform the sort using PHP.
>
> Also, not to be a broken record, but I've asked you twice to try the query using a different data type parameter (FMPro7 -- or 13 if you like -- rather than FMAlt). This really can make a difference.
>
> Best,
>
> --Chris
>
> On Jun 30, 2014, at 9:24 AM, Stephe Pocock <zippyaus at yahoo.com> wrote:
>
>> Hi Chris
>>
>> Thanks for the response.
>>
>> I am not sure what is going on with my solution.
>>
>> As i said, it worked fine under FM11 but under 12 and now 13 it is slow, 18 seconds to load 230 records.
>>
>> Today, I re-wrote the page using the Filemaker php API, I used the same layout and the same find request return the original calculation fields. The results are returned almost instantly. The slowness with FM php is the sorting.
>>
>> Thanks
>>
>> Stephen
>>
>> From: Chris Hansen <chris at iViking.org>
>> To: Stephe Pocock <zippyaus at yahoo.com>
>> Sent: Monday, 30 June 2014 11:06 PM
>> Subject: Re: [FX.php List] Please help with slow code
>>
>> Hi Stephen,
>>
>> So all three of the calculations were UN-stored calcs? Well, if there's no way to create stored versions of the calculations (via periodically re-loaded lookups, for example), then doing the calc in PHP might be faster. That said, it does seem odd that the performance was okay in FM 11 if that's the problem.
>>
>> That brings me to the other possibility: FMAlt vs FMPro7. The reason that FMAlt was introduced was that a bug was introduced in FMS12 related to portals and/or repeating fields as returned by a specific XML schema. (Everything else works fine.) The XML grammar used by FMAlt is much more verbose, and I have seen responses with it take twice as long to load (though typically the difference is quite a bit smaller.) Are there portals and/or repeating fields on the layout in question, and if not, have you tried using FMPro7 as your data type? (Note that you can use FMPro12 as the data type, too, but the output will be no different.)
>>
>> Best,
>>
>> --Chris
>>
>>
>>
>> On Jun 29, 2014, at 10:25 PM, Stephe Pocock <zippyaus at yahoo.com> wrote:
>>
>>> Hi Chris
>>>
>>> There were 6 fields on the layout.
>>>
>>> 3 calculations.
>>>
>>> I have removed the calculations from the php page and layout and the page loads faster, but obviously does not have the required data.
>>>
>>> The thing that bothers me is these are the same pages and setups that we have for Filemaker 11 and we never had the slow loads.
>>>
>>> Are you suggesting that I not use calculations and do all of the calculations in php?
>>>
>>> Thanks
>>>
>>> Stephen
>>>
>>> From: Chris Hansen <chris at iViking.org>
>>> To: Stephe Pocock <zippyaus at yahoo.com>; FX.php Discussion List <fx.php_list at mail.iviking.org>
>>> Sent: Friday, 27 June 2014 12:21 AM
>>> Subject: Re: [FX.php List] Please help with slow code
>>>
>>> Hi Stephe,
>>>
>>> A few questions:
>>>
>>> 1) Are there many excess fields on the layout in question?
>>>
>>> 2) Are there any summary or unstored calculation fields?
>>>
>>> 3) Have you tried performing the query using data type FMPro7? (In this case any integer gte 7 will perform the same.)
>>>
>>> Best,
>>>
>>> --Chris
>>>
>>>
>>>
>>> On Jun 26, 2014, at 3:10 AM, Stephe Pocock <zippyaus at yahoo.com> wrote:
>>>
>>>> Hi
>>>>
>>>> We pretty much use the same code for all our FX pages. Ever since we moved from Filemaker 11 this has been a lot slower to load.
>>>>
>>>> I use the latest FX.php and FMalt
>>>>
>>>> I would greatly appreciate it if someone could review this code and let me know if there is anything out of the ordinary.
>>>>
>>>> <?php
>>>>
>>>> define('DEBUG', FALSE);
>>>>
>>>> include_once("../FX/FX.php");
>>>> include_once("../FX/server_data.php");
>>>> include_once("../FX/FMErrors.php");
>>>>
>>>> $TitleID=$_REQUEST['Initial'];
>>>>
>>>> $cat=new FX($serverIP,$webCompanionPort,'FMAlt');
>>>> $cat->setDBData('FMOnline','TQS_Manual_PHP', 'ALL');
>>>> $cat->SetDBUserPass ($webUN, $webPW);
>>>> $cat->AddDBParam('Initial',$TitleID);
>>>> $cat->AddDBParam('Reference','FMP');
>>>>
>>>> $cat->AddSortParam('Title','ascend');
>>>>
>>>> $catResult=$cat->FMFind();
>>>> foreach ($catResult['data'] as $key => $catData)
>>>>
>>>> ?>
>>>>
>>>>
>>>> <html>
>>>> <head>
>>>> <title>Forms, Manuals and Publications</title>
>>>>
>>>> </head>
>>>>
>>>> <body>
>>>> <table width="600" border="0">
>>>>
>>>> <?php
>>>> $checkHeader = NULL;
>>>>
>>>> foreach ($catResult['data'] as $key => $catData)
>>>> {
>>>> $Title = $catData['Title'][0];
>>>> $URL = $catData['URL'][0];
>>>> $target = $catData['c_URL_target'][0];
>>>>
>>>>
>>>> echo "<tr valign='top'>\n
>>>> <td width='20' height='15'>
>>>> <div align='center'><img src='/Images/Bullet.png' width='9' height='12'> </div></td>\n
>>>> <td><a href='$URL' target='_blank'>$Title</a> </td>\n
>>>> </tr>\n";
>>>>
>>>> }
>>>> // End the foreach loop
>>>> ?>
>>>> </table>
>>>>
>>>>
>>>> </body>
>>>> </html>
>>>>
>>>>
>>>>
>>>> There are less than 100 records and it takes up to a minute to load.
>>>>
>>>> We are using FMS13 on iis 2008R2.
>>>>
>>>> Thanks in advance.
>>>>
>>>> Stephen
>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>>
>>>
>>
>>
>>
>
>
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20140701/cc616262/attachment-0001.html
More information about the FX.php_List
mailing list