find :first vs. find :all in ActiveResource

Anybody know how to differentiate between a find(:first) and a find(:all) call on an ActiveResource system?

# Post.find(:all)
Processing IndexController#index (for 127.0.0.1 at 2008-01-22 00:24:08) [GET]
Parameters: {”action”=>”index”, “url”=>["api", "posts.json"], “controller”=>”index”}
Completed in 0.00234 (428 reqs/sec) | Rendering: 0.00004 (1%) | DB: 0.00000 (0%) | 200 OK [http://localhost/api/posts.json]

# Post.find(:first)
Processing IndexController#index (for 127.0.0.1 at 2008-01-22 00:24:11) [GET]
Parameters: {”action”=>”index”, “url”=>["api", "posts.json"], “controller”=>”index”}
Completed in 0.00256 (390 reqs/sec) | Rendering: 0.00006 (2%) | DB: 0.00000 (0%) | 200 OK [http://localhost/api/posts.json]

Both requests seem identical when coming from an ActiveResource client. I’ve checked the headers but no luck. This is a pain as it means the ActiveResource server does a full listing, returns all the data and then the client selects the first item and throws the rest away. Slow and inefficient.

For now I’ll have to use a :limit parameter or some such and tell clients not to use :first.

Viewing 3 Comments

Trackbacks

close Reblog this comment
blog comments powered by Disqus