In am using the following code in my application,both the applications execute the same result.First one executes fastly than the second one,How can i modify the second one since it is fetching all the values, from there it is limiting 5 rather than the first one User.all.find(:all,:conditions=>["id not in(?)",Person.all],:limit=>5,:order=>''created_at DESC'') User.all.find(:all,:order=>''created_at DESC'').delete_if{|x| x id Person.all.include?(x)}[0..4] -- Posted via http://www.ruby-forum.com/.
Really both quieries look crazy, and will perform poorly on any realistic dataset. I guess Person is a subclass of a User, so if you are using STI just try: User.all(:conditions => "type !''Person''", :limit=>5, :order=>''created_at DESC'') Dmitry
Dmitry Sokurenko wrote:> Really both quieries look crazy, and will perform poorly on any > realistic dataset. > > I guess Person is a subclass of a User, so if you are using STI just > try: > > User.all(:conditions => "type !> ''Person''", :limit=>5, :order=>''created_at DESC'') > > DmitryThanks -- Posted via http://www.ruby-forum.com/.