MySQL gurus?
Author
Discussion

zaktoo

Original Poster:

1,401 posts

270 months

Monday 3rd July 2006
quotequote all
Hi all

Anyone here a MySQL guru please? I need to know if it's possible to limit on the backend the number of rows returned by a query. I have a buggy 3rd-party query builder used by an unknown number of users that can't be taken away from them, but it sometimes creates insane queries that join multiple tables without enough where statements to trim the results appropriately, so I'm seeing massive resultsets from these broken queries. I try to not touch MySQL as far as possible, so I know very little about it ;-) Can I limit either the length of time a query has to return data or the number of possible rows returned somehow?

Thanks

Ciao

Zak

zoidberg

8,883 posts

312 months

Monday 3rd July 2006
quotequote all
You can use the LIMIT statement in a SELECT query. It takes two numeric parameters (start num and end num I think) - have a google for it.

EDIT: SELECT * FROM `your_table` LIMIT 0, 10 will display results 0 - 10

Edited by zoidberg on Monday 3rd July 12:38

zaktoo

Original Poster:

1,401 posts

270 months

Monday 3rd July 2006
quotequote all
Sorry I wasn't clear, but I can't change the query at all, I only can change the parameters the server runs under. Is there anything I can do?

Thanks

Ciao

Zak

judas

6,243 posts

289 months

Monday 3rd July 2006
quotequote all
I'd imagine this is wholly dependent on your development environment.

jamieboy

5,929 posts

259 months

Monday 3rd July 2006
quotequote all
I guess you've found this already but Google mentions the max_select_time option, although every reference I can see has it in the 'to-do' section. I don't have a mySQL installation here at the moment to check, but it might be worth a bit more investigation.

edit - but this thread http://forums.mysql.com/read.php?24,9 suggests it still hasn't made it to release.

Edited by jamieboy on Monday 3rd July 14:40

zaktoo

Original Poster:

1,401 posts

270 months

Monday 3rd July 2006
quotequote all
jamieboy said:
I guess you've found this already but Google mentions the max_select_time option, although every reference I can see has it in the 'to-do' section. I don't have a mySQL installation here at the moment to check, but it might be worth a bit more investigation.


Thanks, will have a squizz ;-)

Ciao

Zak