+1  A: 
Doctrine_Query::create()
            ->select('rec.*')
            ->from('Records rec')                   
            ->limit(5000)
            ->execute();

Try this.. Its will work fine but increase the limit then u will face problems.Retrieving so many records will cause problems..try to change the logic you are using.Indexing etc may solve your problem but i dont have any idea about that..May be some1 here can help you.

piemesons
A: 

When you add a where clause to your DB, it potentially causes it to use indexes, making it much easier on the db engine. It is generally a bad idea to grab an entire table all at once in one DB query, though this may be appropriate for smaller tables. If you're grabbing the whole table at once, it hints that you're misusing the DB, maybe treating it as a glorified file system. In general, the tendency should be to grab only what you need, and where possible due global operations and updates on the DB end.

All that being said, 60s for 20,000 records seems really slow. You may want to check to see if your DB is configured properly (e.g. to use enough RAM and whatnot). You might find the mysqltuner perl script at http://mysqltuner.pl helpful.

Brian
A: 

why do you need in 20k rows in a script??

zerkms
A: 

In the file php.ini of your server installation, you will find the configuration option max_execution_time = 60.

Try setting max_execution_time = 240 or even higher.

Don't forget to restart your webserver after editing php.ini, so the file gets read.

Gnarf
but boss what the benefit of that.. the thing is its taking more than 60 seconds to retrieve 16k records from a db "locally.."
piemesons