© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•7mo ago•
42 replies
dreadfullydistinct

Storing protobuf in the database

Discussing a schema design at work, and what my senior coworker wants to do is this: we have an API definition for the messages we receive over gRPC:

message Message {
    int32 id = 1;
    string message = 2;
    google.protobuf.Timestamp timestamp = 3;
    string username = 4;
    // several other fields, which would be annoying to map
}
message Message {
    int32 id = 1;
    string message = 2;
    google.protobuf.Timestamp timestamp = 3;
    string username = 4;
    // several other fields, which would be annoying to map
}


they want to create the schema like this:

CREATE TABLE messages (
    id SERIAL PRIMARY KEY,
    timestamp TIMESTAMP NOT NULL,
    message_proto BYTEA
);
CREATE TABLE messages (
    id SERIAL PRIMARY KEY,
    timestamp TIMESTAMP NOT NULL,
    message_proto BYTEA
);


where we store some fields for searching and indexing but otherwise just dump the proto we receive. I don't really like this because I don't think it's extensible (what if the customer wants to filter on username later), but I'm curious what wider opinions are
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Reference other files in Protobuf
C#CC# / help
5w ago
❔ Is Storing Predefined Error in Database a good approach
C#CC# / help
3y ago
❔ Source generator & protobuf
C#CC# / help
4y ago
❔ ProtoBuf cannot find imports
C#CC# / help
4y ago