background preloader

Choosing a non-relational database. MySQL to MongoDB - Server Density

Choosing a non-relational database. MySQL to MongoDB - Server Density

MySQL vs. MongoDB: Looking At Relational and Non-Relational Databases | Neon Rain Interactive When building a custom web application you need to consider the type of database that best suits the data. Here's a quick guide on the differences between MySQL (Relational) and MongoDB (Non-Relational / NoSQL). It was back in 2004 that Ruby on Rails first came out and popularized web application frameworks. What you might not know, is that it also popularized ORM (Object-Relational Mapping) layers with its ActiveRecord object. An ORM layer basically provides an object oriented interface to a relational database. That means that instead of writing a query to insert or update a record, you assign some properties to an object and call a save method. For example, if you have a "post" object that represents a blog post, you can access it's comments through the property "post.comments". Thankfully, we never jumped on to the ORM bandwagon. Data Representation MySQL represents data in tables and rows. MongoDB represents data as collections of JSON documents. Querying MongoDB uses object querying.

Simple Service Bus / Message Queue with MongoDB | CaptainCodeman A service bus or message queue allow producers and subscribers to communicate asynchronously so that a system can handle disconnects, processes being stopped and started or enable peaks of demand to be handled beyond what the subscriber can immediately cope with. The queue acts as a buffer that the producer writes to and the subscriber reads from. There are lots of implementations such as NServiceBus, MassTransit, Rhino Service Bus and the cloud-provided services such as Amazon’s Simple Queue Service and Window Azure’s AppFabric Service Bus. Some take a little time to get started with and the cloud ones can also rack up charges pretty quickly if you are doing too much polling. Often, all that is needed is something fairly simple to buffer messages between processes and persist them. Now, I did have a look round first to see if anyone else had created something already and the closest I got was the post here: Why (and How) I Replaced Amazon SQS with MongoDB. Query Flags: AwaitData

MapReduce-MPI Library nosql - Non-Relational Database Design MongoDB as a Message Queue This is a live blog from MongoSV. Here’s a link to the entire series of posts.About.me uses MongoDB for different pieces of infrastructure, but this talk is just about queuing. Originally ran a 3-node RabbitMQ cluster, without disk persistence. Were having trouble diagnosing issues at scale. Looked at some other AMQP options, but decided on MongoDB. Benefits: async ops, per-message (document) atomicity, batch processing, periodic processing, durability, sharding, operational familiarity (n.b. that would be the big one for me!). Use a capped collection? Implementation: Each message is a document. To consume a message they use a findAndModify to grab and remove a document atomically. That’s pretty much it! Benchmarks they ran showed MongoDB outperforming RabbitMQ for message creation by 19% (this is a single-node benchmark on a laptop, FYI). FindAndModify is blocking, so you will see high lock % w/ lots of concurrent consumers. Pros and Cons

Map-Reduce — MongoDB Manual 2.6.4 Map-reduce is a data processing paradigm for condensing large volumes of data into useful aggregated results. For map-reduce operations, MongoDB provides the mapReduce database command. Consider the following map-reduce operation: In this map-reduce operation, MongoDB applies the map phase to each input document (i.e. the documents in the collection that match the query condition). All map-reduce functions in MongoDB are JavaScript and run within the mongod process. Note For most aggregation operations, the Aggregation Pipeline provides better performance and more coherent interface. Map-Reduce JavaScript Functions In MongoDB, map-reduce operations use custom JavaScript functions to map, or associate, values to a key. The use of custom JavaScript functions provide flexibility to map-reduce operations. Map-Reduce Behavior In MongoDB, the map-reduce operation can write results to a collection or return the results inline. MongoDB supports map-reduce operations on sharded collections.

Explaining Non-Relational Databases To My Mom | Ignored by Dinosaurs I was on the phone with Mom yesterday, and we got to talking about technology - a thing that actually happens fairly frequently. Being an only kid, she’s genuinely interested in everything that I do and it’s been helpful to have someone who’s mostly non-technical to bounce explanations off of when I’m getting my head around a new piece of gear. The piece of gear that I was explaining the other day was something called Mongo DB. Mongo’s parent company is called 10gen, and they landed on the startup scene about 5 years ago or so with their flagship product, Mongo DB. The Relational model The relational model of storing data has been around for more than 40 years. The classic example I gave to my mom was that of a common blog. The relational model typically comes into play when you visit a blog that has comments. Issues with the relational model For the purposes of this simplistic example, this hopefully isn’t that hard to get your head around. Very good. The non-relational model

mongoDB で部分一致検索を速くしたい Rails3 で mongoid を使って開発をすることが多くなってきた今日このごろです.レコード数は大変に多いので,テスト環境ではまともな速度が出るのに,いざ実際にとなると全くダメ,返事がかえってこない,ただのしかばねのようなシステムが出来上がったりします. たとえば部分一致検索. aaa aba bba ccc とか,たくさんの列が並んでいるときに,「a」が入っているものを検索したい,とか考えます.mongoDB では Perl みたいな正規表現が使えるので,ワイルドカードなんかを駆使すると,こんなふうに書けます /. 具体的には こんなのをモデルに書きます. ピリオド(.) そこで,インデックスを作成するための表を作ってみようと思います.レコードに「abc」という文字列があったときに,その索引として「bc」「c」も記録しておきます.具体的には abc, abc bc, abc c, abc そして,1 列目に index を張っておきます.ここで重要なのは,全部の部分文字列を記録しておくわけではない,ということです. 検索するときには,ワイルドカードは使いません.使うと遅くなるからです.先頭に探したい文字があるかどうか,だけを見ます.こんなふうになります. /^探したい文字列/ つまり,探したい文字列が先頭にあるかどうかを探します.ここで /^探したい文字列.*/ と 書いても良いじゃないかと思うのですが,というか良いのですが上のものと比べると若干遅くなります. こんなのをモデルに書きます.そして,2列目の文字列を取り出すと検索の出来上がりです. こうすると,大量のデータがあってもそれなりに高速な検索ができます.ちなみに,この考え方は SuffixArray といって,改良版もたくさんあるので,もっと高速化できそうではあるのですが,まぁこのあたりで. ちなみに,このインデックスを作成する表を sharding で分割すると,より速くなります.もちろん 1 列目をキーにして分割しないと意味無いですが.

Nonrelational Databases in a Big Data Environment Nonrelational databases do not rely on the table/key model endemic to RDBMSs (relational database management systems). In short, specialty data in the big data world requires specialty persistence and data manipulation techniques. Although these new styles of databases offer some answers to your big data challenges, they are not an express ticket to the finish line. One emerging, popular class of nonrelational database is called not only SQL (NoSQL). Originally the originators envisioned databases that did not require the relational model and SQL. As these products were introduced into the market, the definition softened a bit and now they are thought of as “not only SQL,” again bowing to the ubiquity of SQL. The other class is databases that do not support the relational model, but rely on SQL as a primary means of manipulating the data within.

Related: