Adrian Pang
Adrian Pang

Reputation: 1135

Why is the write ops count so high for my object?

I need help understanding why one of my model objects that I persist with the datastore costs so much write ops. Looking at the datastore viewer in the dev console, it says that I need 31 write ops to create this object; clicking on the Show Indexes link, I can see that there are two indexes defined for this object (as intended), and reading the documentation:

New Entity Put (per entity, regardless of entity size): 2 Writes + 2 Writes per indexed property value + 1 Write per composite index value

So, if I understand correctly, to create or delete this objects costs 2 writes + 2 Writes * 2 Indexed property value + 0 (I have no composite index value) = 6 write ops?

To modify:

Existing Entity Put (per entity) 1 Write + 4 Writes per modified indexed property value + 2 Writes per modified composite index value

should cost 1 write if non-indexed property are modified, and 5 (or 9) if one or two indexed properties are modified? I am confused as to why the dev console reports 31 write ops needed...

The object is as follows:

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;

...

Upvotes: 1

Views: 303

Answers (1)

Guido van Rossum
Guido van Rossum

Reputation: 16890

Try turning on Appstats. It gives you great insight in where your I/O cost comes from.

The other thing to think about is index writes. The more indexed properties or composite index entries you have, the most it costs to write an entity.

Upvotes: 1

Related Questions