[HELP] How to avoid time execution exceeded...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

[HELP] How to avoid time execution exceeded...

Post by acco »

Hi, i got a DB with 10000 records and i've made a script that for each record check if a determinated value is present in other records of the same DB. Each record that match my search is stored in another table.
Te problem is that this script stops cause it reachs the time limit present in php.ini (i've tried to chage that value to 90 secs but the problem persist). The cycle for a single record take some sec, but all that secs for all record cause the timeout.
How can i do to solve this problem????


Thanks




FABIO
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

10,000 records isn't that much and certainly shouldn't be taking that long. What exactly are you doing with it%AC

I'm not sure but you may be able to disable the max timeout.

Code: Select all

ini_set('max_execution_time', false);
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

i was thinking that i have to change something in my script, cause the check, and all operations if the check match or not, isn't only on 10.000 records, but for each one of the 10.000 i have to check the value in all other 9.999 records!! So in total the script generate 100.000.000 operations! So is normal that is go in timeout...
Any suggestion is very wellcome!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Are you using a database?
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

feyd wrote:Are you using a database?
Yes all my record are in MYSQL database
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you not have the database do the work for you?
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

feyd wrote:Can you not have the database do the work for you?
Not at all, cause the value that i compare is an address and i have to extract it from mysql than i do a while in all db and with a function a do the comparasion of the address with all other address. So i've thinckin that i've to review all my script....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It sure sounds like the database could do it for you.
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

it can not, or i don't know how to do, cause there are not complex function to compare strings.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

How do you need to compare the strings?
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

cause they r manually insered i can have "main avenue, 23" and "main avanue 23" without comma, i can not use a stric comparation, so i used similar_text(), another function, made by me, to check the number present in both strings and link the compartion with other 2 values (the city and zip code) that are insered with a dropdown menu so i can use a stric comparation.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You're comparing the records to each other, yes? I'm fairly sure the database can do the searching for you.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

What version of MySQL are you running? This sounds like something that can be handled at the database level.
acco
Forum Newbie
Posts: 13
Joined: Fri Jan 26, 2007 4:32 am

Post by acco »

Im using Mysql 5.0 (but if needed i can upgrade). You say that my task can handled via databse, but i dont' know how... :(
gavin1996
Forum Newbie
Posts: 22
Joined: Tue Jan 30, 2007 8:30 pm

Post by gavin1996 »

i think that you should create Index On database table
Post Reply