Impact of compactType on Generated Ids?


#1

Can someone clarify what impact the annotation @db(compactType=true) has on auto-generated ids, specifically on relational types?
Consider the following type.

@db(compactType=true)
entity type MyType schema name "MYTYPE"

I notice that when creating new records using .make() and .create() the id that is generated is not a GUID like it normally would be. Instead it is a very short string, sometimes a single character (such as ‘B’).

  • Does the compactType=true also imply a shortId=true?
  • If so, would it be possible to return to GUID ids by explicitly putting shortId=false?
  • Will these short ids run out of space or start to overlap/replace, as the type will eventually hold millions of records?

The use case is that we are generating dynamic reports based on user provided parameters, and this type holds the line-level records of the reports. It is stored in relational instead of Cassandra for greater flexibility (for example, if they ever wanted to know the total value of all lines across multiple reports, or for a single item across multiple reports, that is a simple evaluate for a relational type, but would be manual fetches and aggregations for Cassandra). As these are line-level records, they do not need meta information, the header has that, so it is just a waste of space, hence the compactType=true.


#2

Yes, compactType == true forces short ids. If you only want to avoid having meta, define the meta field with a db annotation of persistable == false.


#3

@trothwein Can you answer the below question as well?

  • Will these short ids run out of space or start to overlap/replace, as the type will eventually hold millions of records?

#4

That shouldn’t be a problem. Types are typically made compact because they have a very large number of entries and the space savings from a shorter id would be significant. Again, if you really only want to not have meta persisted, that might be a better approach.