Reduce or Transformers

29 views
Skip to first unread message

Krzysztof Pajak

unread,
Nov 29, 2014, 3:42:16 AM11/29/14
to rav...@googlegroups.com, krzyszt...@epoczta.pl
Hello Ayende

What is more efficient: Reduce or Transformers ?

When I use Transformers I had to put in my query "Take(int.Max)" and also change config file (<add key="Raven/MaxPageSize" value="2147483647"/>) 
- and it works slowly. 

My sample transformer looks like this:

                TransformResults = products => from prod in products
                                               from manuf in prod.ProductManufacturers
                                               group manuf by manuf.ManufacturerId into g
                                               select new
                                               {
                                                   Id = g.Key,
                                                   Count = g.Count()
                                               };

Thanks for the help.

Regards
Krzysztof

Oren Eini (Ayende Rahien)

unread,
Nov 29, 2014, 4:37:12 AM11/29/14
to ravendb, krzyszt...@epoczta.pl
Reduce is _far_ more efficient.

Please note that by explicitly configuring max page size, especially to such a high value, you are effectively force the system to do a LOT more work, none of which it was designed to do.

If you need to do aggregation, that is why we have map/reduce for.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Krzysztof Pajak

unread,
Nov 29, 2014, 7:15:30 AM11/29/14
to rav...@googlegroups.com, krzyszt...@epoczta.pl
Great, thanks for quick response!

Krzysztof Pajak

unread,
Nov 29, 2014, 9:43:36 AM11/29/14
to rav...@googlegroups.com, krzyszt...@epoczta.pl

If I can't use Transformers, how can I use reduce for query.

My sample object Product has field:

Id, Name, Published, Deleted, List<Categories>, List<Manufacturers>

My sample query:

var query = session.Query<Product>();

query = query.Where(x=>x.Deleted == false);

query = query.Where(x=>x.Categories.Any(new int[1,2]);


I need show List of manufacturers with count of products.

BTW my query has dynamic parameters.

Previously I was using the Transformers and resolved this.

 

Thanks for the help.

Oren Eini (Ayende Rahien)

unread,
Nov 29, 2014, 9:46:05 AM11/29/14
to ravendb, krzyszt...@epoczta.pl
Include the dynamic parameters in the reduce definition, or use dynamic aggregation.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--

Krzysztof Pajak

unread,
Nov 29, 2014, 10:15:30 AM11/29/14
to rav...@googlegroups.com, krzyszt...@epoczta.pl
Thanks,
But where can I find info about Include the dynamic parameters in the reduce definition ?

Regards
Krzysztof

Oren Eini (Ayende Rahien)

unread,
Nov 29, 2014, 10:17:44 AM11/29/14
to ravendb, krzyszt...@epoczta.pl
You don't, you include them in the group by, then you filter on them.
Reply all
Reply to author
Forward
0 new messages