# SOAP for large datasets

**URL:** <https://www.ruby-forum.com/t/soap-for-large-datasets/100541>\
**Category:** Rails\
**Created:** [July 30, 2006, 1:59am UTC](https://www.ruby-forum.com/t/soap-for-large-datasets/100541 "2006-07-30T01:59:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![snacktime](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7feea3/32.png) [@snacktime](https://www.ruby-forum.com/u/snacktime)\
**Post date:** [July 30, 2006, 1:59am UTC](https://www.ruby-forum.com/t/soap-for-large-datasets/100541/1 "2006-07-30T01:59:25Z")

</div>

I’ve been playing around with a soap interface to an application that  
can return large datasets (up to 50mb or so). There are also some  
nested structures for which I’ve used ActionWebService::Struct with  
2-3 nested members of oher ActionWebService::Struct members. In  
addition to chewing up a ton of memory, cpu ulilization isn’t that  
great either. My development server is a dell 2600 Xeon 1.8mghz.  
It seems like creating all of the nested structures might be what’s  
eating all the cpu. Cpu utilitzation goes up to almost 70%.

A simpler application where I just use plain xml in the request and  
response, and use a bit of to\_xml and REXML for building the trees  
still takes a good amount of memory but nowhere near the amount of  
cpu.

The data is from 3 tables. Customers, transactions, and orderitems.  
I created a struct for customers and in customers there are two  
members that contain a struct for transactions and orderitems.

Right now the code looks like this. Any ideas on how to optimize it?  
Or even ideas on better methods then using soap for something like  
this?

@orders = Customer.find(:all, :include =\> [:orderitems, :histories],  
:conditions =\> [“history.trans\_date between ? and ?”,start\_date,end\_d  
ate], :limit =\> 500)

```
for order in @orders

  oi = []
  for items in order.orderitems
    oi << OrderitemData.new(:sku => items.sku, :item_type =>

```

items.item\_type, :descript =\> items.descript, :amount =\> items.amount,  
:quan  
t =\> items.quant, :trans\_id =\> items.trans\_id, :trans\_date =\>  
items.trans\_date)  
end

```
  trans = []
  for history in order.histories
    trans << TransactionData.new(:sale_type => history.sale_type,

```

:order\_id =\> order.order\_id, :trans\_id =\> history.trans\_id, :outcome  
=\>  
history.outcome)  
end

```
  ar << CustomerData.new(:orderitem_data => oi, :transaction_data

```

=\> trans, :address =\> order.address, :address2 =\> order.address2,  
:f\_na  
me1 =\> order.f\_name1, :l\_name1 =\> order.l\_name1)  
end  
ar  
end
