为什么写操作对我的对象来说如此之高?

时间:2012-06-03 05:56:02

标签: java google-app-engine google-cloud-datastore

我需要帮助理解为什么我持有数据存储区的模型对象之一会花费如此多的写入操作。查看开发控制台中的数据存储区查看器,它表示我需要31个写操作来创建此对象;单击Show Indexes链接,我可以看到为此对象定义了两个索引(按预期),并阅读文档:

  

新实体投放(每个实体,无论实体大小):每个索引属性值写入+ 2个写入+每个复合索引值写入1个

所以,如果我理解正确,创建或删除这个对象成本2写+ 2写* 2索引属性值+ 0(我没有复合索引值)= 6写操作?

修改:

  

现有实体投放(每个实体)1每个修改的索引属性值写入+4个写入+ 2个每个修改后的复合索引值写入

如果修改了非索引属性,

应该写入1,如果修改了一个或两个索引属性,则应该写入5(或9)?我很困惑为什么开发控制台报告需要31个写操作...

对象如下:

public class Media implements IMedia {

private static final long serialVersionUID = 1657456300412658003L;
// Get a file service
private static FileService fileService = FileServiceFactory.getFileService();

@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
@Persistent
private String title;

@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
@Persistent
private String author;

@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private Text description;

@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private MediaType mediaType;

@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String fullPath;

@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String fileName;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private long size;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private String contentType;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private boolean isDeactive;
@Persistent
private String chartId;
@Transient
private IChart chart;
@Persistent
private boolean approved;

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

@Persistent
private Date imageDate;
@Transient
private BlobKey blobKey;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private float imageLatitute = 190;
@Persistent
@Extension(vendorName="datanucleus", key="gae.unindexed", value="true")
private float imageLongitute = 190;

private static final long serialVersionUID = 1657456300412658003L; // Get a file service private static FileService fileService = FileServiceFactory.getFileService(); @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") @Persistent private String title; @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") @Persistent private String author; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private Text description; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private MediaType mediaType; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private String fullPath; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private String fileName; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private long size; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private String contentType; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private boolean isDeactive; @Persistent private String chartId; @Transient private IChart chart; @Persistent private boolean approved; @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private Date imageDate; @Transient private BlobKey blobKey; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private float imageLatitute = 190; @Persistent @Extension(vendorName="datanucleus", key="gae.unindexed", value="true") private float imageLongitute = 190;

1 个答案:

答案 0 :(得分:1)

尝试启用Appstats。它可以让您深入了解I / O成本的来源。

要考虑的另一件事是索引写入。您拥有的索引属性或复合索引条目越多,写入实体的成本就越高。