PDA

View Full Version : pagination


Haros
12-01-2008, 01:25 PM
I have a php - mysql problem.

I have a script that fetches data from the internet to update some fields in a db. In particular, I take the artist name from the table, seek the music genre on the internet and update the genre field.

The problem is that my db sometimes has too many artists... (50-100) and when I try to get their music genre I get an execution timeout because the script takes too long to fetch the data.

So I thought of geting 10 rows at a time fetch their genre and then move to the next 10 (if you have a better walkthrough please tell me).

My question is how is it possible to do this in my application?

Something I need to note: The script will be so loaded only at the first times that it will be used, the data fetchd will be stored in my db so if I need to use them again later they will be fetched from my server...

abduraooft
12-01-2008, 02:07 PM
Check http://www.codingforums.com/showthread.php?t=151398

Haros
12-01-2008, 02:38 PM
Hmm from a quick look I think that that's not what I am looking for.
I don't want to display a certain amount of rows and browse to them by 10. I want to fetch data from internet by 10 rows and I think that this cannot be done by a single php page (I have the page execution timeout problem).

guelphdad
12-01-2008, 06:49 PM
you need indexes on your table. you should also show the sql query you are using.

1) mysql can handle millions of rows if tuned and indexed properly so having 50-100 artists is not all that big

2) if you commit a cross join your query can be larger than you think

3) if you don't have indexes and have a cross join effect then you can really bog down your query.

Fumigator
12-01-2008, 06:56 PM
I believe the bog down the OP is experiencing is when he/she petitions an external website/data warehouse for information he/she does not yet have in his/her own database. I think that's what he/she is referring to when he/she says "I have a script that fetches data from the internet".

I think abdurasoft's link page also has coding to limit the results as the OP requires.

abduraooft
12-02-2008, 08:06 AM
I believe the bog down the OP is experiencing is when he/she petitions an external website/data warehouse for information he/she does not yet have in his/her own database. I think that's what he/she is referring to when he/she says "I have a script that fetches data from the internet".

Sorry for being off topic. I had found an easier way to refer such cases, s/he :D

Fumigator
12-02-2008, 04:39 PM
Ah but then how do you handle the his/her scenario? :eek::p

guelphdad
12-02-2008, 05:46 PM
If they're married she's always right and he's right when she's not around. ;-)

abduraooft
12-04-2008, 08:07 AM
If they're married she's always right and he's right when she's not around. ;-)Lol. :D

oesxyl
12-04-2008, 06:49 PM
If they're married she's always right and he's right when she's not around. ;-)
that means we must use count to see if are both or simply use she/her? :)

I have a php - mysql problem.

I have a script that fetches data from the internet to update some fields in a db. In particular, I take the artist name from the table, seek the music genre on the internet and update the genre field.

The problem is that my db sometimes has too many artists... (50-100) and when I try to get their music genre I get an execution timeout because the script takes too long to fetch the data.

So I thought of geting 10 rows at a time fetch their genre and then move to the next 10 (if you have a better walkthrough please tell me).

My question is how is it possible to do this in my application?

Something I need to note: The script will be so loaded only at the first times that it will be used, the data fetchd will be stored in my db so if I need to use them again later they will be fetched from my server...
did you profile the script, where it spend time?

best regards