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.
Add New Comment
Viewing 3 Comments
Thanks. Your comment is awaiting approval by a moderator.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Do you already have an account? Log in and claim this comment.
Add New Comment
Trackbacks
(Trackback URL)