4 ms·
I looked into using some kind of NoSQL solution at work, and one thing puzzles me. Assume a key/value database, where values are JSON documents or something sim
by tzs 16y ago
I looked into using some kind of NoSQL solution at work, and one thing puzzles me. Assume a key/value database, where values are JSON documents or something similar.
Using such a database, with the key being customer account ID, and the value being a document that contains all the information about that customer's account would be convenient and useful. Information about the account would include things like name, address, email, status of the account, when their subscription to our service expires, re-billing information, all their purchases, and so on.
This would definitely be a lot more convenient than our current SQL-based solution for two of the three things we do with our customer data.
One of those things is display a customer's information for our customer support people when they are dealing with the customer on the phone, or working on a ticket in our help desk. With the NoSQL, it would be a simple get the JSON document for that customer, and display it nicely.
The second thing is providing information to the installed software on the end user's computer. Our software provides a service that can partly be done locally, and partly requires back end support. All the back end information needed to support a given customer's installed software would be in that JSON document, so again the key/value store would work great.
However, I'm at a loss as to how the third thing would be handled efficiently: reporting.
For instance, suppose I'm asked for a quick report on how well a new SKU has sold over the last week. With our SQL database, this is a trivial select from the "orders" and "line_items" table. It is almost instantaneous. With the NoSQL solution, it would appear that I would have to go look at every single customer's entry.
All in all, we've got a couple dozen regular reports, many running hourly, and a few being interactive on-demand via a web interface, that are fairly straightforward and efficient in our SQL-based solution (some might involve joining 6 or 7 tables, but it is still straightforward and efficient).
Thus, at first glance, it would seem that going to NoSQL would be a nightmare for my reports. Many times an hour, it would appear that the database would get slammed by reports that would have to be accessing every freaking record in the database. That doesn't sound like something that's going to make me happy.
How do people deal with reporting when using NoSQL?
- thezilch 16y agoWhy not keep a count running in the SKU's document?
- tzs 16y agoThat could work. However, what happens when I'm asked to break down my report by whether the purchasers of the SKU were new customers or returning customers? (Also, a count is not sufficient, since someone might want the report run for a specific date range). I could keep two counts in the SKUs document, of course. It doesn't sound very efficient, though, if the procedure when asked for some new report is that I have to go modify the database document layout to specifically support that new report, then do some kind of back fill, and then modify the code that processes orders to fill in the new stuff as orders are processed. As I said, I didn't get far into NoSQL, so maybe it is a lot easier than it seems to me now.
- artsrc 16y agoIf an SQL (any) database is fast there are a few possibilities: 1. There is an index 2. The database is in memory and a scan is running in process 3. The query result was precomputed 4. The query was not that hard With couchdb you could create a view on sku and week, and reduce to a count.
- tzs 16y agoI'll have to give couchdb a look.