Should I be using mySQL or MongoDB [closed] - mysql

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
There is alot of talk at the moment about NoSQL from my understanding Mongodb is one of them, to me the NoSQL seems that it is SQL just not in the same sense that we know mySQL.
Think of it this way, they both store data, one does it by a fixed database with so called limits while another stores data when it thinks it the best time to store data and supposable has not limits or very few.
However this is confusing to web developers who are making the switch or thinking about making the switch. In my case I work for a big teleco company and making a switch like this is something that needs to be really looked at, and we cant relay on something that has no physical being so to say.
Maybe I am not understanding the meaning of NoSQL, maybe I have the meaning correct.
I am in the process at the moment re-writing the whole CMS that we use, and would kinda be nice to know should I spend the time looking at noSQL or keep MySQL (which does not seem to have any issues that the moment)
We only have 5000 rows in the customer details and in the backup with have 14000, it gets backed up just incase the master table decides to screw up.

Are you being forced to select one or another? If not, why limit the potential solutions of solving your business requirements by having to do 'this' or having to do 'that'. I equate the workflow steps of software engineering to those of a doctor.
A doctor has to make a number of decisions to ensure the operation goes successfully. This includes diagnosis, determining the incision points, and selecting the required tools of their trade; scalpel, bone-saw, etc. to complete the operation. If you told the doctor that they could only do the operation with a crossbow, the end results won't work out well for the patient or the doctor (malpractice).
So stepping away from the clumsy analogy, here are a few reasons why I opt to use both, (using an online bookstore as an example):
Book data such as ISBN, author name(s), dates published, etc. are stored in a RDBMS (let's say MySQL). By storing this type of data in MySQL I can run any number of queries to present to a user. For example, I can run a query returning you all books published by authors whose last name being with the letter Z, and a publish date of 2005, ordered by their ISBN descending. This type of data manipulation is critical when creating useful features for your company (or clients).
Book assets, such as cover art are stored on the filesystem using a NoSQL solution. This solves two problems. First, I don't want voluminous data ballooning up my MySQL database (blobs) so I'll store this data on the filesystem. And secondly, a book's cover art has nothing to do with any of the actual book data (people really going to want all books with the color blue in their cover art?). And we simply cannot forgo a book's cover art, as it could make or break a sale when a user is browsing our online inventory.
In closing, my recommendation to you is to select any and all the tools you need to finish the operation successfully, and in a way which makes it easy to add new features in the future.

With such data, MySQL wouldn't be a problem. NoSQL db are designed for large data sets, and are quite different designed(everything you can do in NoSQL you can also do in sql db).
Besides, NoSQL are far more harder to administrate. Cassandra needs right config to be faster than normal MySQL db, if not it is much slower(and even then you can have few problems with it). And for most NoSQL you need VPS/dedicated hostage.

NoSQL databases are worthy of some evaluation, but they have a niche that they suit and it's not CMS' with 5,000 rows.
I think you should stick with a proper relational, SQL-based database. You may find PosgreSQL to be a better free choice than MySQL, but you'll have to evaluate this yourself1.
1 There's a variety of resources for this, for instance: http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL.

Related

From MySql to NoSql [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What I've got right now with Mysql
Here is my database:
I search users by location a lot using bounding box.
There are two more tables: user_tag and tags. The overall database size is about 1 Gb.
I've implemented an arbitrary tag system with these tables, so that when user wants to use tag that hasn't been created yet, this tag is inserted in tag table.
I also search users by tags.
Benchmarks
I have no indexes in this database except those on primary keys.
As you can see there are a lot of inserts and they take much time.
Main problem here is time consuming inserts and updates.
Create new Event with tags(~150ms):
http://pastebin.com/vyw6qhrN
Update Event(~200ms):
http://pastebin.com/f28yvn9z
What I don't like in this solution:
When I create new user I do insert in 3 tables to link the user with his tags.
When updating user information I also need to do 3 updates and 1 deletion or insert when user changes tags.
Searching users by tags gets really messy (complex query) (How to implement tag system)
What can I get with NoSql
I want to use a document oriented database. Then I will need only one collection:
{
"name": "Dan",
"lat": 60
"lon": 30
"tags":["football", "fishing"]
}
I will be able to set index on tags and lat and lon for faster search.
My questions
Should I switch to NoSql or I can somehow improve my current implementation. Or maybe switch to a different RDBMS?
In case I should switch: What NoSql database is the best in this case?
In case I should switch to MongoDb: Is it reliable and mature enough? Because I've read a lot of posts about people going away from MongoDb. For example: http://www.reddit.com/search?q=mongodb
Both technologies can probably solve your problem. Some scenarios are easier to handle with a RDBMS, others with a more specialized database. It depends on the details of your requirements, your experience and your personal preferences.
#mvp commented on the "convenience of SQL". Personally, I find SQL a major pain because object-oriented and SQL aren't easy to map. People often use their ORM behemoths, which I find an antipattern -- chances are the ORM code size is more than 50 times the entire application code you have so something is fishy. But that is just my opinion, SQL is still probably the most common data store.
Personally, I have the feeling your problems maps to MongoDB quite nicely, because
It has geo indexes and supports various geo queries
It is very easy to create simple tagging, if that is what you need
It's easy and handling a few GB of data is easy, too.
It's easy to administer. I don't need to meddle with innodb_buffer_pool_size or whatnot at that scale.
Joins are overrated. Joins are needed, because you split up data that belongs together to squeeze it into tables. If you want to find answers to questions like "users who like football and live in foo also like?", the aggregation framework and caching are easier and more scalable than huge joins.
If I were you, I'd sit down for a day or two and give it a spin: You have a reasonably sized data set so you can do testing with real-world data, and changing just a few queries should be very easy. It will be fun and you get a feeling for the upsides and downsides first hand.
By the way, three of the articles on reddit refer to each other: "Don't use MongoDB" on pastebin, Eliot Horowitz' answer at news.ycombinator.com and "The MongoDB story was a hoax", so no, MongoDB doesn't just crash randomly and have a gazillion bugs. But of course, it's not a silver bullet that just magically makes scaling issues disappear.

Sqlite3 vs Postgres vs Mysql - Rails [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I guess this has been brought up many times, but I'm bringing it up again!!!
Anyway... In Ruby on Rails Sqlite3 is already setup and no extra picking and slicing is needed, but...
after numerous readings here and other places, some say it's not scalable while others say it can actually be quite good at that. Some say MySQL is much better for bigger projects, while others think, just go with PostgreSQL.
I'm interested in hearing your opinion on this. In two scenarios. One where you are starting a little website for news publishing website like CNN news, and the other scenario where you're creating a website similar to Twitter?
Highly depends on your application.
Generally spoken, any write operation into a SQLite database is slow. Even a plain :update_attribute or :create may take up to 0.5 seconds. But if your App doesn't write much (killer against SQLite: write to DB on every request!), SQlite is a solid choice for most web apps out there. It is proven to handle small to medium amounts of traffic. Also, it is a very good choice during development, since it needs zero configuration. It performs also very well in your test suite with the in-memory mode (except you have thousands of migrations, since it rebuilds from scratch every time). Also, it is mostly seamless to switch from SQLite to, eg MySQL if its performance isn't enough any longer.
MySQL is currently a rock-solid choice. Future will tell what happens to MySQL under Oracle.
PostgreSQL is the fastest one as far as I know, but I haven't used it in production yet. Maybe others can tell more.
I'd vote for Postgres, it's consistently getting better, especially performance wise if that's a concern. Taking you up on the CNN and Twitter examples, start out with as solid footing as you can. You'll be glad later on down the road.
For websites, SQLite3 will suffice and scale fine for anything up to higher middle class traffic scenarios. So, unless you start getting hit by millions of requests per hour, there's no need to worry about SQLite3's performance or scalability.
That said, SQLite3 doesn't support all those typical features that a dedicated SQL server would. Access control is limited to whatever file permissions you can set for UNIX accounts on the machine with your database file, there's no daemon to speak of and the set of built-in functions is rather small. Also, there's no stored procedures of any kind, although you could emulate those with views and triggers.
If you're worried about any of those points, you should go with PostgreSQL. MySQL has (indirectly) been bought by Oracle, and considering they also had their own database before acquiring MySQL, I wouldn't put it past them to just drop it somewhere along the line. I've also had a far smoother experience maintaining PostgreSQL in the past and - anecdotally - it always felt a bit snappier and more reliable.
DISCLAIMER:
My opinion is completely bias as I have used mysql since it first came out.
Your question brings in another argument about how your development environment should be setup. A number of individuals will argue that you should be using the same dbms in development as you do in testing/production. This is totally dependent upon what you're doing in the first place. Sqlite will work fine, on development, in most cases.
I've personally been involved with more sites using MySql and MsSql than Postgres.
I was involved in a project that scrubbed the National Do-Not-Call list against client numbers. We stored that data locally. Some area codes easily have over 5 million records. The app was initially written in .Net using MsSql. It was "not-so-fast". I changed it to use PHP and MySql (Sad says before I found out about Ruby). It would insert/digest 5 million rows in(about) 3 seconds. Which was infinitely faster than processing it through MsSql. We also stored call log data in tables that would grow to 20 million records in less than a day. MySql handled everything we threw at it like a champ. The processing naturally took a hit when we setup replication but it was such a small one that we ignored it.
It really comes down to your project and what solution fits the need of the project.

database architecture for very many records (for example messages in social network) [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I want to understand how to build a large site database architecture for chat messages.(example facebook.com or gmail.com)
I think that messages is redistributed in different tables because having all the messages in one table is impossible, the reason is they have huge quantity right? (and here partitioning can't I think)
So, what logic is used to redistribute messages in different tables? I have several variants but I think none of them is an optimal variant.
So generally, I'm interested in what you may think about this? and also, If you know some good articles about this, please post the link.
The answer currently is hadoop
They have a distributed file system and a database that can use that http://hbase.apache.org
http://en.wikipedia.org/wiki/HBase
OK, well the problem is how to partition the dataset. The easiest (and often the best) way to think about this is to consider the access pattern. what messages are needed quickly, which ones can be slow, and how to manage each of them.
Generally older messages can be held on low network speed/low memory/very large storage nodes (multi-terabyte).
New messages should be on high bandwidth network/high memory/low storage nodes (gigabytes are enough).
As traffic grows, so you'll need to add storage to the slow nodes, and add nodes to the fast nodes (scale horizontally).
Each night (or more often) you can copy old messages to the historical database, and remove the messages from the current database. Queries may need to address two databases, but this is not too much trouble.
As you scale out, the data will probably need to be sharded i.e. split by some data value. User-id splits makes sense. To make life easy, all sides of a conversation can be stored with each user. I would recommend using time bucketed text for this (disk access is usually on 4k boundaries) though this may be too complicated for you initially.
Queries now need to be user-aware so they query against the correct database. A simple lookup table will help there.
The other thing to do is to compress the messages on the way in, and decompress on the way out. Text is easily compressed and may double your throughput for a small cpu increase.
Many NoSQL databases do a lot of this hard work for you, but until you've run out of capacity on your current system, you may wish to stick to the technologies you know.
Good luck!
A while ago there was a article how reddit did from small to large.
They dont have a user message-system, but I guess this will work out for alooooot of scenarios with huge amounts of data
http://highscalability.com/blog/2010/5/17/7-lessons-learned-while-building-reddit-to-270-million-page.html
Edit: the "interesting" part about the database is #3 - dont worry about the schema.. they use 2 tables for everything. Thing and Data.
Facebook uses Apache Cassandra for some of their storage (document database), and heavy use of memcached to make it scale well.
Here's more about FB's nuts and bolts.
You might also find some gems in the FB developer news.

When not to use MySQL or other relational DBs? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
Simple question, when should one not use MySQL?
There are two facets to my curiosity:
When to avoid MySQL in particular?
When to not use relational databases in general?
I wanted to be sure of my choice of MySQL (with PHP on Apache) as my employer was insistent on using something that's not free or open-source but I insisted otherwise. So I just want to be sure.
When your data is not relational, or when (based on your data access pattern and/or data model) you can choose better model, than the relational, use it. If you are not sure there is a better model for your problem, use RDBMS - of of the reasons of it's popularity is that it fits really good for most of the problems. Facebook and Google use MySQL (although not only MySQL, but major part of Facebook is on top of MySQL), so thing about this when you considering a NoSQL solution.
There are different type of databases, like graph databases, which are good for specific tasks. If you have such specific task, research the field of the task.
As for choosing vendor for a RDBMS, this is more a business objective, then a technical one. Sometimes the presense of support, certified professionals, training/consulting, and even matching the company infrastructure (if it has extensive Windows network and experienced windows-administrator it may prefer using windows server over a linux-based one) are the reasons particular software to be choosen.
1. When to avoid MySQL in particular?
When concurrent database sessions are both modifying and querying the database.
MySQL is fine for read-only or read-mostly scenarios (it is no accident that MySQL is frequently used for Web), but more advanced multi-version concurrency control capabilities of Oracle, MS SQL Server, PostgreSQL or even Firebird/Interbase can often handle read-write workloads not just with better performance but with better correctness as well (i.e. they are better at avoiding various concurrency artifacts that may endanger data consistency).
Even traditional "locking" databases such as DB2 or Sybase are likely to handle read-write workloads better than MySQL.
2. When to not use relational databases in general?
In short: when your data is not relational (i.e. it does not fit well in the paradigm of entities, attributes and relationships).
That being said, many modern DBMSes have capabilities outside traditional relational model, such as ability to "understand" hierarchical structure of XML. So even unstructured data that would not normally be stored in the relational DB (or at best would be stored in a BLOB) is no longer necessarily off-limits.
Not a difficult question to answer. Don't use MySQL if another DBMS is going to prove cheaper / better value. Other leading DBMSs like Oracle or SQL Server have many features that MySQL does not. Also if your employer already has a large investment in other DBMSs it may be prohibitively expensive and difficult to support MySQL without good reason. For what reason are you insisting on MySQL?
Also bear in mind that no business buys a DBMS. They buy a complete solution of which the DBMS is part. Consider the return on investment of the whole solution and not just the DBMS.

MySQL vs PostgreSQL for Web Applications [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am working on a web application using Python (Django) and would like to know whether MySQL or PostgreSQL would be more suitable when deploying for production.
In one podcast Joel said that he had some problems with MySQL and the data wasn't consistent.
I would like to know whether someone had any such problems. Also when it comes to performance which can be easily tweaked?
A note to future readers: The text below was last edited in August 2008. That's nearly 11 years ago as of this edit. Software can change rapidly from version to version, so before you go choosing a DBMS based on the advice below, do some research to see if it's still accurate.
Check for newer answers below.
Better?
MySQL is much more commonly provided by web hosts.
PostgreSQL is a much more mature product.
There's this discussion addressing your "better" question
Apparently, according to this web page, MySQL is fast when concurrent access levels are low, and when there are many more reads than writes. On the other hand, it exhibits low scalability with increasing loads and write/read ratios. PostgreSQL is relatively slow at low concurrency levels, but scales well with increasing load levels, while providing enough isolation between concurrent accesses to avoid slowdowns at high write/read ratios. It goes on to link to a number of performance comparisons, because these things are very... sensitive to conditions.
So if your decision factor is, "which is faster?" Then the answer is "it depends. If it really matters, test your application against both." And if you really, really care, you get in two DBAs (one who specializes in each database) and get them to tune the crap out of the databases, and then choose. It's astonishing how expensive good DBAs are; and they are worth every cent.
When it matters.
Which it probably doesn't, so just pick whichever database you like the sound of and go with it; better performance can be bought with more RAM and CPU, and more appropriate database design, and clever stored procedure tricks and so on - and all of that is cheaper and easier for random-website-X than agonizing over which to pick, MySQL or PostgreSQL, and specialist tuning from expensive DBAs.
Joel also said in that podcast that comment would come back to bite him because people would be saying that MySQL was a piece of crap - Joel couldn't get a count of rows back. The plural of anecdote is not data. He said:
MySQL is the only database I've ever programmed against in my career that has had data integrity problems, where you do queries and you get nonsense answers back, that are incorrect.
and he also said:
It's just an anecdote. And that's one of the things that frustrates me, actually, about blogging or just the Internet in general. [...] There's just a weird tendency to make anecdotes into truths and I actually as a blogger I'm starting to feel a little bit guilty about this
Just chiming in many months later.
The geographical capabilities of the two databases are very, very different. PostgreSQL has the exceptional PostGIS extension. MySQL's geographical functionality is practically zero in comparison.
If your web service has a location component, choose PostgreSQL.
I haven't used Django, but I have used both MySQL and PostgreSQL. If you'll be using your database only as a backend for Django, it doesn't matter much, because it will abstract away most of the differences. PostgreSQL is a little more scalable because it doesn't hit the brick wall as fast as MySQL as data-size/client-count increase.
The real difference comes in if you are doing a new system. Then I'd recommend PostgreSQL hands down, because it has a lot more features which make your DB layer much more customizable, so that you can fine-tune it to any requirements you might have.
Although it's a bit out of date, it would be worth reading the MySQL Gotchas page. Many of the items listed there are still true, to the best of my knowledge.
I use PostgreSQL.
I use both extensively. My choice for a particular project boils down to:
Licensing - Are you going to distribute your app (IANAL)
Existing Infrastructure and Knowledge Base
Any special sauce you have to have.
By special sauce I mean things like:
Easy/cheap replication = MySQL
Huge dataset problems with small results = PostgreSQL. Use the language extensions, and have very efficient data operations. (PL/Python, PL/TCL, PL/Perl, etc)
Interface with R Statistical Libraries = PostgreSQL PL/R available in debian/ubuntu
Well, I don't think you should be using a different database brand in anything past development (build, staging, prod) as that will come back to bite you.
From how I understand it PostgreSQL is a more 'correct' database implementation while mySQl is less correct (less compliant) but faster.
So if you are pretty much writing a CRUD application mySQL is the way to go. If you require certain features out of your database (if you're not sure then you don't) then you may want to look into postgreSQL.
If you are writing an application which may get distributed quite a bit on different servers, MySQL carries a lot of weight over PostgreSQL because of the portability. PostgreSQL is difficult to find on less than satisfactory web hosts, albeit there are a few. In most regards, PostgreSQL is slower than MySQL, especially when it comes to fine tuning in the end. All in all, I'd say to give PostgreSQL a shot for a short amount of time, that way you aren't completely avoiding it, and then make a judgement.
Thank you. I've used Django with MySQL and it's fine. Choose your database on the features you need. Hard to compare MySQL and Postgres. Better to compare Postgress to SQl Server.
#WolfmanDragon
PostgreSQL has (tiny) support for objects, but it is, by nature, a relational database. From its about page:
PostgreSQL is a powerful, open source relational database system.
MySQL is a relational database management system while PostgreSQL is an object-relational database management system. PostgreSQL is suited well for C++ or Java developers, as it gives us more control over how queries are written. ORDBMS also gives us Objects and User Defined Types. The SQL queries themselves are much closer to the ISO standards than MySQL.
Do you need an ORDBMS or a RDBMS? That will better answer your question.