Google应用程序引擎(Java)-JDO PersistenceManager使PersistentAll变慢
我有一个应用程序是迷你CRM。我正在尝试添加允许批量用户导入的功能。上载处理程序从CSV文件读取数据,然后调用my CustomerService类将客户对象存储在数据存储中:Google应用程序引擎(Java)-JDO PersistenceManager使PersistentAll变慢,java,google-app-engine,google-cloud-datastore,jdo,Java,Google App Engine,Google Cloud Datastore,Jdo,我有一个应用程序是迷你CRM。我正在尝试添加允许批量用户导入的功能。上载处理程序从CSV文件读取数据,然后调用my CustomerService类将客户对象存储在数据存储中: public int createCustomers(final List<Customer> customers) { List<List<Customer>> buckets = bucketList(customers); int bucketCount = 0;
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();
}
我已经在开发(本地)和生产应用程序引擎中对此进行了测试,但没有结果。我认为这是一个比较常见的用例,将大量数据导入系统并将其快速保存到数据存储中。我尝试了很多方法来实现这一点:
-使用AsyncDatastoreService
-逐个保存客户对象(makePersistent)
-使用客户中的密钥对象作为主键
-使用accountNumber字符串作为主键
但是似乎没有什么能起到很大的作用。建议您特别关注大量对象的“持久化过程”。您可以减少泵入“makePersistentAll()”
的对象数量,这样您就有了几个调用。显然,可能是GAE/数据存储的一些奇怪之处导致了这种情况。建议您特别关注大量对象的“持久化过程”。您可以减少泵入“makePersistentAll()”
的对象数量,这样您就有了几个调用。显然,可能是GAE/数据存储的一些奇怪之处导致了这种情况
@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;
...