Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3798148
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:31:27+00:00 2026-05-19T13:31:27+00:00

I have an otherwise perfectly relational data schema in place for my Postgres 8.4

  • 0

I have an otherwise perfectly relational data schema in place for my Postgres 8.4 DB, but I need the ability to associate arbitrary key/value pairs with several of my tables, with the assigned keys varying by row. Key/value pairs are user-generated, so I have no way of predicting them ahead of time or wrangling orderly schema changes.

I have the following requirements:

  • Key/value pairs will be read often, written occasionally. Reads must be reasonably fast.
  • No (present) need to query off of the keys or values. (But it might come in handy some day.)

I see the following possible solutions:

  1. The Entity-Attribute-Value pattern/antipattern. Annoying, but the annoyance would be generally offset by my ORM.
  2. Storing key/value pairs as serialized JSON data on a text column. A simple solution, and again the ORM comes in handy, but I can kiss my future self’s need for queries good-bye.
  3. Storing key/value pairs in some other NoSQL db–probably a key/value or document store. ORM is no help here. I’ll have to manage the separate queries (and looming data integrity issues?) myself.

I’m concerned about query performance, as I hope to have a lot of these some day. I’m also concerned about programmer performance, as I have to build, maintain, and use the darned thing. Is there an obvious best approach here? Or something I’ve missed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T13:31:28+00:00Added an answer on May 19, 2026 at 1:31 pm

    That’s precisely what the hstore datatype is for in PostgreSQL.
    http://www.postgresql.org/docs/current/static/hstore.html

    It’s really fast (you can index it) and quite easy to handle. The only drawback is that you can only store character data, but you’d have that problem with the other solutions as well.

    Indexes support “exists” operator, so you can query quite quickly for rows where a certain key is present, or for rows where a specific attribute has a specific value.

    And with 9.0 it got even better because some size restrictions were lifted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a slight annoyance with my heroku push/deploy process, which otherwise has been
From Day One I was told that each third-party iOS app was perfectly sand-boxed
I have the following code so far: /* * This method adds only the
I have a timer in the main application form. The timer displays a nag
I have the following functions: which (x:xs) = worker x xs worker x []
I have an application which needs to be able to create folders in UAC-protected
Current Code I have two functions as f1::Int->Int->Int f1 a b | a==1 &&
Have you noticed that every 10 questions on this site is about jQuery? Anyway...
I have been given an assignment to drop one of our product's dll and
I was reading an article referenced by Jeff Atwood about Yahoo's Best Practices for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.