# Record Layer Primary Key Prefixes

**URL:** <https://forums.foundationdb.org/t/record-layer-primary-key-prefixes/4539>\
**Category:** Record Layer\
**Created:** [June 28, 2024, 7:41pm UTC](https://forums.foundationdb.org/t/record-layer-primary-key-prefixes/4539 "2024-06-28T19:41:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArnieW](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@ArnieW](https://forums.foundationdb.org/u/ArnieW)\
**Post date:** [June 28, 2024, 7:41pm UTC](https://forums.foundationdb.org/t/record-layer-primary-key-prefixes/4539/1 "2024-06-28T19:41:09Z")

</div>

I have the option set in protobuf for a primary key:

 ![Screenshot 2024-06-28 at 12.39.24 PM](https://global.discourse-cdn.com/foundationdb/original/2X/6/68f291b2fd4da2de5c974c4ec2b3dd2e81e42bdd.png)

calling `loadRecord` with a plain Tuple.from($email) is loading the record, which is unexpected (how does it know which primary key to append?)

What is the proper usage for explicit primary key prefixes? Thanks.

---

<div class="post-metadata">

**Author:** ![MMcM](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@MMcM](https://forums.foundationdb.org/u/MMcM)\
**Post date:** [July 1, 2024, 7:06pm UTC](https://forums.foundationdb.org/t/record-layer-primary-key-prefixes/4539/2 "2024-07-01T19:06:37Z")

</div>

I would expect

```plaintext
Record type UserEmailRecord must have a primary key

```

based on just the snippet here, which does not even show the whole message.

One possible explanation for not getting an error is that `UserEmailRecord` isn’t included in the `RecordTypeUnion` and the loaded record is some other type altogether.

There is currently no way in just the `.proto` to get a compound primary key. It might not be unreasonable to deduce from the record type having a record type key that `[(field).primary_key = true]` should mean that it gets `recordType()` plus that. But that would be an enhancement. You probably need to use `RecordMetaDataBuilder` and `setPrimaryKey`.
