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 …

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.

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

Frederick C. 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).

Fred

so is it it is possible in mysql.
for other database adapter will it be fast ? is it ?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs