Possible to get a record count from find without transferring the whole result set?

16 views
Skip to first unread message

Cedric Tineo

unread,
Oct 31, 2010, 6:05:41 AM10/31/10
to RFM Community
I am currently using this to get a record count of a found set after
a .find

@record_count = @my_layout_light.find({
"status_published" => 'OK',
"composite_name" => @name,
{:include_portals => true}
).size

The problem is that it forces RFM to retrieve the entire result set,
that's all the fields of the used layout for all the records of the
found set - in its xml form to ruby / nokogiri - and only after all
that has been processed, it is available for the .size method...
Needless to say that on large found set of a few thousands, this takes
many_many seconds to process.

Since I only want a record count to display "Your search returned XXX
results" and I'm only displaying 10 at a time on a page - it's a waste
of time to have to transfer the whole set - just for a record count.

Any other way to do that?

lardawge

unread,
Oct 31, 2010, 1:14:39 PM10/31/10
to RFM Community
@record_count = @my_layout_light.find({
"status_published" => 'OK',
"composite_name" => @name},
{:include_portals => true,
:max_records => 10}
)

@record_count.foundset_count

Hope that helps.

Cedric Tineo

unread,
Nov 12, 2010, 3:29:44 PM11/12/10
to RFM Community
Brilliant! Thanks!

Just out of curiosity - in which part of the doc should I have looked
to find out about that?

Thanks again, Cedric
Reply all
Reply to author
Forward
0 new messages