views:

33

answers:

2

I'm looking for a NoSQL database that allows queries that return records that fall in the specified range.

I'm not very good with the NoSQL nomenclature (as I'm still only researching whatever they will be viable) so I'll explain it how I would do it in SQL.

What I'll need to do, is search for records (let's say forum posts), that are above a specific score. More or less something like this: SELECT * FROM posts WHERE score > 2.

The question being, when I'm using PHP, is it possible to do with any NoSQL database (key-value or wide column ones)? If it's impossible with any, which NoSQL databases support such queries?

+1  A: 

You may want to check out MongoDB. It's popular1, and supports range queries:

Unlike many other non-relational database solutions, any field can be queried at any time. MongoDB supports range queries, regular expression searches, and other special types of queries in addition to exactly matching fields. Queries can also include user-defined JavaScript functions (if the function returns true, the document matches).

From: Wikipedia - MongoDB Features

Here's how your SELECT * FROM posts WHERE score > 2 query would look like in Mongo:

db.posts.find( { score : {$gt: 2} } );

Further reading:


1 See: MongoDB : Production Deployments

Daniel Vassallo
I'm correct in finding that the MongoDB removes the Durability from ACID?
Hubert Kario
@Hubert: It's a trade off. You may want to check out this SO question: [Is there any NoSQL that is ACID compliant?](http://stackoverflow.com/questions/2608103/is-there-any-nosql-that-is-acid-compliant). MongoDB still remains one of the NoSQL solutions that suppost many features from SQL databases.
Daniel Vassallo
@Hubert: You might also be interested in this: http://www.mongodb.org/display/DOCS/Durability+and+Repair and this: http://blog.mongodb.org/post/381927266/what-about-durability
Daniel Vassallo
I know, that's the problem with noSQL databases, I just want to know which part of ACID it drops to achieve the performance, this way I could write an application around to mitigate this problem. If I cared about 100% ACIDity I wouldn't be looking at NoSQL solutions but went straight to PostgreSQL :)
Hubert Kario
Looks like it's exactly what I need, many thanks!
Hubert Kario
A: 

OrientDB supports SQL with extensions for the schema-less paradigm.

You can execute this query:

SELECT * FROM posts WHERE score > 2

But the underlying index is not used with operators different by = (equals). So it could be not so fast with millions of records because it need to scan the entire cluster to satisfy the condition (something similar to a table in relational world).

Lvca
Then it won't be good for my needs, two reasons: using a "greater than" score is only part of the query (possibly also other non-equal like) and second: I do need queries like that to be very fast
Hubert Kario
This feature is planned for the next release: http://code.google.com/p/orient/issues/detail?id=64. How much records are we talking about? millions or billions?
Lvca
millions, but I plan on running it on VPS, so I need all the performance I can get :)
Hubert Kario