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

  • Home
  • SEARCH
  • 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 5995439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:57:36+00:00 2026-05-22T23:57:36+00:00

I have a need to store data using the HSTORE type and index by

  • 0

I have a need to store data using the HSTORE type and index by key.

CREATE INDEX ix_product_size ON product(((data->'Size')::INT))
CREATE INDEX ix_product_color ON product(((data->'Color')))
etc.

What are the practical limitations of using expression indexes? In my case, there could be several hundred different types of data, hence several hundred expression indexes. Every insert, update, and select query will have to process against these indexes in order to pick the correct one.

  • 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-22T23:57:37+00:00Added an answer on May 22, 2026 at 11:57 pm

    I’ve never played with hstore, but I do something similar when I need an EAV column, e.g.:

    create index on product_eav (eav_value) where (eav_type = 'int');
    

    The limitation in doing so is that you need to be explicit in your query to make use of it, i.e. this query would not make use of the above index:

    select product_id
    from product_eav
    where eav_name = 'size'
    and eav_value = :size;
    

    But this one would:

    select product_id
    from product_eav
    where eav_name = 'size'
    and eav_value = :size
    and type = 'int';
    

    In your example it should likely be more like:

    create index on product ((data->'size')::int) where (data->'size' is not null);
    

    This should avoid adding a reference to the index when there is no size entry. Depending on the PG version you’re using the query may need to be modified like so:

    select product_id
    from products
    where data->'size' is not null
    and data->'size' = :size;
    

    Another big difference between regular and partial index is that the latter cannot enforce a unique constraint in a table definition. This will succeed:

    create unique index foo_bar_key on foo (bar) where (cond);
    

    The following won’t:

    alter table foo add constraint foo_bar_key unique (bar) where (cond);
    

    But this will:

    alter table foo add constraint foo_bar_excl exclude (bar with =) where (cond);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large amount of data I need to store, and be able
I have a need to create a transactional process using an external API that
I need to store some data in an ini file, and I have run
Using MySQL for basic storage of system/user data. I need to store/search messages (adding
I have some columns in a data store using 12 decimal precision. I want
I have a situation where I need to store some data that just won't
I need to store data that looks like this: <root> <child-one> value 1 value
What is the best way to store data that is dynamic in nature using
I'm designing a new system, and I have need to store a pretty large
We are using ASP.Net MVC TempData to store form data between page refreshes. We

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.