Pokkai Dokkai
2007-Dec-21 05:40 UTC
Limit & offset ,will it be fast ? in combine query. urgent
i have a small doubt. if i write combine query in Model.find() WITH limit & offset to get 10 records per hit .but my friend told that when to get last 10 records then the time will be same as to get Model.find() WITHOUT limit & offset. he told like that ,the data base will create a temp table to keep our (query result table) then it will get corresponding number of records from the new table like records (0..10,10..20,20..30..........).then he told by this way to get last 10 records ,it will be same time as ordinary Model.find() WITHOUT limit & offset is it correct ? any idea .. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg
2007-Dec-21 06:36 UTC
Re: Limit & offset ,will it be fast ? in combine query. urgent
What kind of drugs is your friend on? There is no temporary table creation for storing records, unless he''s talking about Rails 2.0 new "query caching". Doing a find with limit and offset will of course be quicker than doing it without because it''s not fetching as much data from the table. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-21 08:22 UTC
Re: Limit & offset ,will it be fast ? in combine query. urgent
database drugs? It''s quite possible for mysql to materialize temporary tables for the purpose of evaluating a query. With any if these things you can always ask the database (on mysql EXPLAIN SELECT * from foos limit 100,200) what it would do. If your find clause also has a sort order then you''d better have an index on that column or it could be dog slow (since then the database has to sort the entire table to find the top 10 records). Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pokkai Dokkai
2007-Dec-21 18:04 UTC
Re: Limit & offset ,will it be fast ? in combine query. urge
Frederick Cheung wrote:> database drugs? > > It''s quite possible for mysql to materialize temporary tables for the > purpose of evaluating a query. With any if these things you can always > ask the database (on mysql EXPLAIN SELECT * from foos limit 100,200) > what it would do. > > If your find clause also has a sort order then you''d better have an > index on that column or it could be dog slow (since then the database > has to sort the entire table to find the top 10 records). > > Fredso is it it is possible in mysql. for other database adapter will it be fast ? is it ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---