2013-03-07 107 views
1

我有一個應用程序是一個mini-CRM。我正在嘗試添加功能以允許批量用戶導入。上傳處理程序從一個CSV文件中讀取數據,然後調用我的CustomerService類的客戶對象存儲在數據存儲:Google App Engine(Java) - JDO PersistenceManager makePersistentAll減速

public int createCustomers(final List<Customer> customers) { 
    List<List<Customer>> buckets = bucketList(customers); 
    int bucketCount = 0; 
    PersistenceManager persistenceManager = PMF.get().getPersistenceManager(); 
    for(List<Customer> bucket: buckets) { 
     Collection<Customer> makePersistentAll = persistenceManager.makePersistentAll(bucket); 
    }   
    return customers.size();   
} 

遺願清單方法只是打破了大名單分解成較小的列表。我這樣做是爲了調整應用程序,看看是否有makePersistentAll調用的最佳大小。我目前已將它設置爲1000,並正在使用包含100,000條記錄的CSV文件進行測試。隨着更多記錄的添加,應用似乎越來越慢,特別是在60K記錄標記附近。我試過設置我的所有領域中的客戶將沒有索引的,但是這似乎並沒有做任何noticable區別:

@PersistenceCapable 
public class Customer implements Serializable { 

@PrimaryKey 
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
private Key key; 

@Extension(vendorName="datanucleus", key="gae.unindexed", value="true") 
@Persistent 
private String accountNumber; 
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true") 
@Persistent 
private String email; 
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true") 
@Persistent 
private String firstName; 
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true") 
@Persistent 
private String lastName; 
    ... 

我在開發(本地)測試這個問題,以及生產應用引擎但無濟於事。我認爲這是一個比較常見的用例,將大量數據導入系統並將其快速保存到數據存儲區。我已經嘗試了很多東西來實現它: - 使用AsyncDatastoreService - 逐個保存客戶對象(makePersistent) - 在客戶中將Key對象用作主鍵 - 將accountNumber字符串用作主鍵

但似乎沒有什麼區別。

回答

相關問題