hI, I have a fairly complex mysql query which span through ~500000 records and multiple tables ...which take almost 30 secs to run and generates ~5000 rows . The query has been optimised. Now ... i want to do the foll with this 1> Paginate ...I do not want to rerun the query with LIMIT/OFFET clause etc. The object obtained in the first place.Can it be some how stored and reused? 2>Sort on different combination of columns ...here also I want to use ruby and do all the functionality. But how to save the active record object and reuse it . Basically I want to avoid the 30 second delay for each query. Cheers Rajib --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On May 14, 2:25 am, BENI <rajib.chakraba...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> hI, > > I have a fairly complex mysql query which span through ~500000 records > and multiple tables ...which take almost 30 secs to run and generates > ~5000 rows . > > The query has been optimised. > > Now ... i want to do the foll with this > > 1> Paginate ...I do not want to rerun the query with LIMIT/OFFET > clause etc. The object obtained in the first place.Can it be some how > stored and reused? > > 2>Sort on different combination of columns ...here also I want to use > ruby and do all the functionality. >1) optimise it some more, use explain select ..., make sure you understand what is going on. Maybe you can structure you data so that the query isn''t so complicated 2) cache it (memcached etc...) Fred> But how to save the active record object and reuse it . > > Basically I want to avoid the 30 second delay for each query. > > Cheers > > Rajib--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Also, that sounds like a very expensive query to leave in the hands of indiscriminate users. It''s such a costly query it sounds like there should be another way to do it. Any chance it''s a once-per-day type job that you could off load to a background process or cron job? Another possibility would be warehousing the data (e.g., ActiveWarehouse, if the project is still active) and supporting queries only on data that has been warehoused. On May 14, 4:21 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 14, 2:25 am, BENI <rajib.chakraba...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > hI, > > > I have a fairly complex mysql query which span through ~500000 records > > and multiple tables ...which take almost 30 secs to run and generates > > ~5000 rows . > > > The query has been optimised. > > > Now ... i want to do the foll with this > > > 1> Paginate ...I do not want to rerun the query with LIMIT/OFFET > > clause etc. The object obtained in the first place.Can it be some how > > stored and reused? > > > 2>Sort on different combination of columns ...here also I want to use > > ruby and do all the functionality. > > 1) optimise it some more, use explain select ..., make sure you > understand what is going on. Maybe you can structure you data so that > the query isn''t so complicated > 2) cache it (memcached etc...) > > Fred > > > But how to save the active record object and reuse it . > > > Basically I want to avoid the 30 second delay for each query. > > > Cheers > > > Rajib--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---