Question

In my actual project I am immersing in a "bigdata" problem. We need store a big database where the read performance is important over the write (data changes are minimal and they are controlled).

There are millions of registers, and each register has a lot of key/value information.

I'm testing noSQL databases and in my investigation I found hstore. I know very good postgresql, but I acknowledge that I did not know this module.

I'm reading about hstore performance and I am impressed, but I have a doubt: It's only possible store text as values, so, Is search by a numeric value impossible? Of course, it's necessary keep good performance for reading operations. For example, search registers who values of "X" was greater than "10".

If it is impossible, there are alternatives?

Thanks

Was it helpful?

Solution 2

While you can do semantically correct searches of any data type with hstore by using casts in your queries, this comes with several costs:

  • You can't use the generic GiST indexing for hstore. You must instead create specific indexes on particular hstore keys cast to specific types.

  • You're incurring the overhead of casting all the rows each time you process them. This is cheap-ish for something like a text to integer cast, but if you're casting text to numeric or an array, say ... that's going to hurt.

If your data is almost exclusively free-form key/value, trying to jam it into an RDBMS probably isn't ideal. PostgreSQL 9.4 might do this better with the enhanced JSON support, but it's a bit early to say.

OTHER TIPS

Yes it is possible to search for numerics if you cast the value:

select k -> 'k'
from (values
    ('k => 11'::hstore),
    ('k => 010')
) h(k)
where (k -> 'k')::integer >= 10;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top