Re: Re: Looking to improve DB_DataObject performance for loops
| From: | Alan Knowles | Date: | Fri, 05 Nov 2004 00:29:08 +0000 |
| Subject: | Re: Re: Looking to improve DB_DataObject performance for loops | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15346@lists.php.net to get a copy of this message | ||
I did something similar before - making invoices for > 6000 members. with 50000+ transactions per month.
In the end, I broke it down so it would generate invoices in groups (eg. A | B | C | D ..... etc.)
I script that generates invoices for letter A, then sends some javascript to redirect to the next letter in the sequence.
It will be interesting when I get close to finishing DBDO to see if it helps, but I suspect it's just the database performance can not handle that much data being passed around and queried.
Regards
Alan
Mike Zornek wrote:
On 11/1/04 9:13 PM, "Alan Knowles" <alan@akbkhome.com> wrote:although It's know that 'new' is slower than cloning, I doubt this is significant enough for you to notice.. - you probably need to reduce the calls to the database.. (or cache the results somewhere.) why not do: $member->whereAdd('member_id in (1,2,3,4,5,6,7)'); $member->find(); while ($member->fetch()) { $c = clone($member); $c->doSomethingToMember(); } Regards AlanI implemented this and am seeing about a 10% increase in speed. It's not where I need to be but it's a start. To give some more insight, the problem is this. I am building a member database. I am offering my user (admin of the member db) to run a search of our database and then from a pull down menu choose an action to perform on each member returned. Some actions include Make invoices, Change status, List emails. Right now the biggest problem for me is in make invoices, which take a good amount of member data and produces a multi-page PDF of invoices we mail out. It also edits the DB slightly, recording that we are sending them an invoice today. The inherit problem is that the search results they will be acting on will be anywhere from 5,000 - 6,000 members and to loop through each as DB_DataObjects just takes too much time. Most browsers will crap out around 300 seconds, Apple's Safari at 60! One thought I have to to have the user place an "order for invoices" where in it will store the order in the DB and then I could have a cron script run every so often looking for orders. When an order is received it runs the order via the command line PHP, with an extending execution time. At the end of the order the person whom requested it will get an email with success and urls to any files they might want to download, ala the big PDF. Sorry if this is a bit off topic, any suggestion appreciated. ~ Mike ----- Mike Zornek Web Designer, Media Developer, Programmer and Geek Personal site: <http://MikeZornek.com>