Advanced MySQL Am I missing the point? [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.
Am not sure if this question makes sense. But I know all the basic CRUD commands of mysql. Probably a bit more here and there (foreign keys etc). But there are so many books written on mysql/dbms. I can write decent queries and get all my results as I want them. Maybe they aren't the most efficient but it worksforme. Thats because my apps arent facebook as yet that I have to worry about optimization. Or do I?
Am I missing the point here? What else should I know?
Thank you very much.

Premature optimization is the root of all evil. Focus on designing proper and logical database structures and indexing them correctly, that will take you far. Modifying a badly written query is always easier than modifying a badly designed database structure.
In my opinion, use the queries you have and optimize them when there is a need for optimization. What comes to the queries, rather focus on making them secure (see sql injection).

What else should I know?
Greater understanding of relational theory, so you write better SQL. I'm currently enjoying "SQL and Relational Theory," a new book by C. J. Date, the world's leading expert on the relational model.
Implementing and monitoring security - SQL injection certainly, but other issues covered by OWASP, SANS.org, or books like "19 Deadly Sins of Software Security." This is a broad topic not specific to SQL, but I think it's every software developer's duty to learn this stuff.
Performance measurement and monitoring - how will you know when you reach the point where you do need to learn optimization techniques?
I18N, L10N, character sets.
Database maintenance and recovery - backups, repair.
Replication, clustering, and proxying.
Deployment and upgrade techniques - how to apply changes to a running application or site without interrupting service.
Writing more-or-less portable SQL that works with multiple RDBMS brands. At least understand what needs to be rewritten if you need to support another brand.
How and when to employ Object-Relational Mapping frameworks.
How and when to employ non-relational databases. SQL is the best general-purpose data management paradigm, but there are other technologies more specialized to specific tasks.

Advanced MySQL is probably not just about writing queries for CRUD operations. Sometimes you need to do optimizations or various maintenance procedures that do require an intimate knowledge of the DBMS you are working with. You might not be worried about the performance of your queries and the robustness and efficiency of your database design if you deal with small to medium sized applications, but for a highly scalable application all these are factors that you have to take into account.

It's good to know CRUD syntax well. I would recommend that you go beyond that to understand relational design, primary and candidate keys, indexing, etc. These are topics that are meaningful for all relational databases, not just MySQL.

Databases are much more than just "Places to put stuff". Once you realize that, you will start using them to their full potential.

You should worry about optimization anyway imho. Sure if right now you have only 10 people who are using your application it's not the issue, but in the future if the user base grows it can really be a "pain in the ass" to rewrite database structure, especialy if in your code you are using the raw queries without database abstraction.

If you know enough to to do what needs to be done, then you know enough for now. However, Introduction to Database Systems by C.J. Date is an outstanding discussion of relational databases written by a pioneer in the field (as well as other types of database systems).

Generally, there are tons of features of mysql and other RDBMS systems that people aren't aware of. This is fine since you can get by well with a subset of features, but to deal with difficult problems or to be a good DBA there's a huge amount of stuff to learn. When people talk about Advanced X on databases, these are the types of things that are meant.
To answer your question, it's never a bad idea to find out what other features and tools are out there. You may find much better ways of solving your own problems and develop a better set of skills for solving other people's problems. I also fully agree with the other answers suggesting that you improve your knowledge on higher level topics, knowing how to make good db designs is extremely important.

Oh, now I get it (the question). I thought you meant "What is the point of combining 'Advanced' and 'MySQL'?". :-)
If you MUST use MySQL for your job, then yes, you had better gradually get a deeper understanding of it, especially what the shortcomings and gotchas are, and how other people at work may make assumptions about things that are not really going to work out.
Now, my "troll": if this is just you, use something a bit more robust. I'm no MicroSoft fan, but they do make the startup costs for using SQL Server pretty low, assuming you are working on Windows. Better yet, if you are working on a *nix server, you might try PostgreSQL. They have been pretty serious about correctly implementing quaint little things like ROLLBACK, transaction isolation, foreign key referential integrity, views, functions (aka stored procedures) for quite a few years. MySQL has improved over the years, but is still (IMHO) somewhat immature. My impression of it back around 2000 was "the reliability of xBASE with the ease of the SQL interface". (I'm not a big fan of the SQL language itself -- maybe I'm just too old to really warm up to it as the "the only possible way to do it")

I avoid MySQL like a bad flu bug, but I can add some insight here.
One area that would be covered in the "advanced" portion of MySQL is customization.
There is alot involved with SQL in general that MySQL doesn't do out of the box, or can be customized. Our company uses full stored procedure implementation and geospatial queries as two examples.
Advanced would involved good customization skills, and experience adding and working with customizations or add-ins. Anything to make MySQL be more enterprise like.

Related

PostgreSQL or mySQL best for daily log website? [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 11 years ago.
I know that both these databases are better for different scenarios but in terms of a website where users will login and enter numerical data to a daily log, which one would it be best to use? I read that mySQL is faster to begin with but PostgreSQL is more scalable if the website were to start getting a lot of users?
The downside is that my host only offers mySQL and so to use postgreSQL I would have to purchase VPS hosting which is more expensive. I have also read people advising people to not worry about it to begin with, however it concerns me that I would have to rewrite queries and forms if I later moved to postgreSQL? I would appreciate everyone's thoughts on this.
I don't understand why people have given this question negative marks when I clearly stated that I am from a finance background and only started learning 3 weeks ago. I think you need to remember that everyone has to start somewhere and that we haven't all been doing this as a job/hobby for years. I would love to see some of you come out of your comfort zone and come and do my job for a day as you would be equally as clueless and I can guarantee that I would not be so rude as some of you have been here. You should be trying to create an environment of learning and innovation, rather than an environment of arrogance. If everyone knew everything, what would be the point in this website?
Disclaimer: I have worked a lot more with PostgreSQL than with MySQL
From a performance/scalability point of view both are probably pretty much the same. There are workloads where Postgres is better and there are workloads where MySQL is better. Unless you test it in your environment it's hard to tell which one would work better for you.
Postgres seems (seemed?) to be faster in a workload with a lot of concurrent writes, whereas MySQL seems to be better with heavy read-only workload. But those benchmarks are about 3-4 years old now, so they are probably no longer true - especially since InnoDB in MySQL 5.5 improved a lot in that area.
However PostgreSQL's SQL features are far more advanced than MySQL's and MySQL has a tendency to silently ignore things you tell it to do - especially in a default installation (and if you rely on a foreign key to be created that might be a very unpleasant surprise). MySQL still has an advantage in terms of clustering as far as I can tell.
They are both equal when it comes to High Availability solutions.
I strongly disagree with the opinion that one should avoid any DBMS specific features - utilizing all features of a DBMS will make your application more scalable and will increase performance.
Traditionally MySQL wasn't known for stability and quality of their releases, but that seems to have improved since Oracle has taken over.
I still don't like MySQL's release policy where they introduce major changes and features in minor releases. The PostgreSQL dev team has a much more strict policy about what goes into a minor release. Upgrading a minor release (i.e. bugfix releases) is much less "dangerous" in PostgreSQL than it is in MySQL.
Someone once said the big difference between the PG development and MySQL is: the Postgres team first makes sure your data is safe, then it makes sure everything is working correctly, then it makes it fast. Whereas the MySQL team first makes it fast, then correct and finally stable. But that too might have changed since the Oracle takeover.
Personally I'd always prefer PostgreSQL over MySQL because of the much better SQL feature set and the overall quality of the product.
MySQL is the more popular solution and is used by very large companies for very large databases, so MySQL is far from unscalable.
If you want the ability to move between both databases at a later date in case you decide to switch, I would recommend using an ORM (Look at http://www.doctrine-project.org/); this way you'll only have to write the queries once and if you change to a different database down the road, you only need to change a config variable. Doctrine will also have you build your database structure in a YAML file which it can convert for you as well.
It's also capable of migrating between database types.
You'll also want to take into account the different MySQL Engines which perform differently as well. I was just looking at a comparison between PostgreSQL and MySQL which in their conclusion, they didn't like the fact that MySQL wasn't built with transactions, however, InnoDB does provide transactional support for MySQL as well as speed and memory improvements in some cases.
So the bottom line is this: If you can make your application in such a way that you can use either database (as mentioned above) run your own benchmarks against your application and your databases and see what kind of a difference it makes to you.
There's certainly other things to think about if you have the budget for it and that's getting DBA's specific to the database you're using and get them to optimize it.
First, SQL is SQL, be sure that you use strict SQL, then you don't rewrite anything. The different between the both dbs is the level of SQL support. PosgreSQL has better support, but the support by MySQL depends on the used storage engine.
Yes, you can better scale your application with PostgeSQL, but how mach load have you on your server? 1GB per day, less more?

Database Management System for db-heavy, busy website/application?

EDIT: I've learnt, and it's probably true that YouTube uses MySQL. But it probably would be the enterprise edition and not free edition. The only alternative seems to be PostgreSQL. Long question short - - Can PostgreSQL used instead of MySQL? Is it a very good alternative in any case?
Firstly, I noticed that these are the most common names when it comes to (relational) database management systems - - DB2 (IBM), Oracle Database, Microsoft SQL, Ingres, MySQL, PostgreSQL and FireBird. So, should I presume these are the best?
Okay, of the above - - DB2 (IBM), Oracle Database and Microsoft SQL, the so-called Enterprise DBMSs, come with a bill; while MySQL (exclude enterprise version), PostgreSQL and FireBird are open source and free.
As should be clear from my previous questions here, I plan to build a photo-sharing site (something like Flickr, Picasa), and like any other, it's going to be database-heavy and (hopefully) busy.
Here's what I would love to know: (1) does any one of the free DBMSs stand up to the mark with the paid enterprise DBMSs? (2) Can any of the free DBMSs scale and perform well for enormous and busy databases without too much headbanging and facepalming?
Things in my mind w.r.t the DB:
Mature
Fast
Perform great/fine under heavy load
Perform great/fine as database grows
Scalable (smooth transition)
support for languages (preferably Python, PHP, JS, C++)
Feature-rich
etc (whatever I am missing)
PLZ NOTE: I know Facebook, Twitter etc use (or at least used) MySQL, and I see reports from time to time, how their sysadmins cry over that decision. So, please don't say, XXX uses it, so why can't you. They've started small, I am too. They've made mistakes, I don't want to. I want to keep the scaling-transition smooth. I hope I am not asking too much. Thanks.
"Which is the best database" is a huge question and is the subject of much contention. I've noticed on StackOverflow there is a tendency to close such questions; although the question is interesting, it is also quite unresolvable ;-)
FWIW, I would go with this:
Use what you know
If it doesn't conflict too heavily with the first rule, use something that is free of charge
Use what works with other parts of your stack
Use what you can hire for at reasonable cost (so, maybe not Oracle unless you really have to)
Don't optimise too early. Working slowly is much better than an unfinished, efficient website.
Also, scalability is not really to do with your db platform, but to do with how you design your site. Note also that some platforms scale better when adding more servers (MySQL) and others do better when increasing your server resources (PostgreSQL).
Please note as of today, MySql is not a free project aka as free as postgresql. One of the main reason why i had to switch over to PG. (Thankx to NPGSQL and PgAdmin III, it was a lot easier than it was rumoured)
However MySql does have number of advantages related to applications,addons,forums and looked good on resume.
PostgreSql is a much mature DBMS. It is a objectRDBMS. It has been around for more than 15 years. It is not known to have defaulted on any major issues. It is well known to handle transactions running in millions of rows successfully. The most important is, it's high rate of compliance with SQL standards. Infact in professional circles, it is more of an Oracle of Free RDBMS rather than MySql of popular applications.

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.

What's up with mysql? [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've seen in a few places on the internet that the future for MySQL is bleak. Mainly people talking poorly about it. Is MySQL really "dying"? If this is the case.. what are good alternatives to database solutions? I work for a small company and we use a lot of MySQL. Is postgre a good solution? What's something that would be useful to learn how to use in the event I go to a larger company? What is the standard corporate database(please don't say oracle)?
MySQL is very well established and shows no signs of going anywhere. People are always predicting this or that will die off, but it's all just a bunch of noise. Still, I would learn multiple databases as you will be a more well rounded developer. Knowing Oracle is very valuable on the job market.
Sorry but Oracle, SQL Server, MySQL, Postgres are all good databases. You are asking what will make you marketable and the best way to look at that is to look at what ALL you do and how that has to do with databases. Are you strictly a DBA, then look that up on a jobs site and see how many jobs are for MySQL DBA. Oracle and SQL Server will probably have more.
Are you a programmer that uses MySQL? Well, that's different because you should be more database agnostic. As a programmer you should be able to jump to any database (even language) and learn quickly.
Also, Oracle and SQL Server have free versions you can learn with so you can use them to learn.
As to "larger company," I would suggest looking around at what you consider to be a "larger company" and see what they use. Where I work we use MySQL, Sql Server, Oracle, and anything that will do the job (sqlite, etc.), but if there was a standard it would be Oracle and SQL Server.
As to your fears - anything can go belly up. Look at the world's history to see that. Nothing is certain. Study broadly.
edit:
That depends on the job description. You HAVE to do research to see what the market is wanting. Big big companies like big big money databases (because they are good databases, incidentally). They just do. Are there some that like MySQL, sure but not as many, in my opinion. You must search the market. That is what everyone does when they are trying to figure out what is needed out there. You could replace your entire question with a programming language and you'd have the same answer - research. There are whole sites dedicated to what's hot in the market (don't believe them all btw). I'm sure MySQL wouldn't hurt but if the job calls for Oracle and you don't know how to even list the tables in Oracle (which is not show tables), then why would they hire you? But again, depends on what you are doing, just DBA, programmer, what? You may never have to list the tables if you are a programmer because the DBAs won't let you touch the database. Research.
For the future of MySQL I would rather let one of the creators do the talking : http://askmonty.org/w/images/a/a4/Osd2010.pdf
Not to mention that oracle just made InnoDB (a very popular MySQL storage engine) commercial only. http://www.cloudave.com/7356/internal-email-on-why-a-software-company-migrates-away-from-mysql/
Needless to say it is not going anywhere but it is not free to use for sure (never was actually but now oracle will ensure GPL anytime they want).
After MySQL, PostgreSQL is the most used open source free (as in beer) database.
On the commercial (high cost) side. Oracle is still the most used database. But it is most certainly an overkill if your software does not need a DBA as a monthly maintenance cost to the customer.

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.