If you've found yourself in the MySQL space even for a little while, you already know that MySQL and other flavors of it offer a couple of data types for developers to choose from. A wide majority of the most popular data types offered by MySQL are related to text — in this space, MySQL offers VARCHAR
, CHAR
, TINYTEXT
, TEXT
, and other options. In this article, we are going to go through the similarities and differences between two of some of the most popular options: the aforementioned VARCHAR
and CHAR
.
What Is CHAR and VARCHAR?
Before diving deeper into the differences between the two data types, we must first make you understand what they are, right? Well, everything in this space is pretty simple because the names of the data types themselves suggest what they are able to do — CHAR
stands for "character values" and VARCHAR
stands for "variable character values."
Deriving Ideal Indexes: A Guide
Indexes are there to simplify our work when searching for data: they speed up SELECT
queries at the expense of slowing down other kinds of queries like DELETE
s, UPDATE
s, and INSERT
s instead. However, as awesome as indexes might be, they also need a lot of work to get right — in this blog, we will tell you how you should go about deriving ideal indexes for your database. The majority of the examples in this article will focus on MySQL: however, the concept is the same for all major database management systems available on the market today.
What Are Indexes?
If you are familiar with database structures, great — because that's essentially what indexes are! Indexes are database structures that can be used to quickly find rows having specific column values. At the expense of taking up disk space and time if your tables are big and you find yourself adding indexes on top of them, indexes allow databases to skip reading through entire tables and instead, only scan relevant rows which means that databases have less data to scan through.
The Darker Side of ALTER TABLE
If you frequently find yourself immersed into the MySQL world, there's probably no need to explain to you what SQL queries are and what they do. Chances are, you know them like your five fingers. SELECT
queries allow us to read data, INSERT
queries allow us to insert data into a given database, UPDATE
queries allow us to update data for certain rows or for the entire table if we wish, DELETE
queries let us delete records from a table, etc. If you've ever dug deeper into the world of MySQL though, you must know that there is one more query that is very important for both database administrators and developers — that query is ALTER TABLE
.
What Is ALTER TABLE?
Simply put, ALTER TABLE
is a query in MySQL that allows us to modify (or ALTER
) the structure of a table. The things that ALTER TABLE
can do are numerous — ALTER TABLE
can be used to change names of tables or columns, or add or modify columns as well. On its end though, ALTER TABLE
is mostly used when indexes are involved — when developers need to add indexes, they change the structure of their tables, and that's where ALTER TABLE
comes into play once again.
How Does MySQL Configuration Work?
If you've found yourself in the MySQL space at least for a little while, chances are that you have heard about one of its well-known files: my.cnf. my.cnf is a configuration file exclusive to MySQL and all of its flavors and it's widely regarded as the "go-to" file whenever MySQL configuration errors occur. Sure, we can set up a couple of settings when we start MySQL with the "--" options, but that doesn't do much - it's much more effective to set the settings inside of the configuration file instead.
Why Does MySQL Need a Configuration File?
First things first, we will look into why MySQL needs a configuration file in the first place. After all, MySQL is a powerful beast as-is, right? Well, not quite. You see, these days MySQL is running on a very wide variety of infrastructures and database servers - some servers might have 20TB of hard drive space and 256GB of RAM allocated to them, others - like small virtual private servers or the like - might only have 2GB of space and 256MB of RAM. The difference here is huge and the primary purpose of configuration files in this scenario is to provide an "endpoint" for MySQL DBAs and developers to configure it according to their requirements.
Security vs. Performance in the SQL World
If you found yourself inside of the world of databases in one way or another, you already know a little about database security and performance. Database management systems certainly do come with benefits to your databases, but have you thought about what options you need to weigh from the security and performance perspectives for your choice to be the most effective? That’s what we’re going to explore in this post.
Are Security and Performance Linked Together?
One of the first things we would like you to consider is the fact that performance and security are very closely intertwined. The main reason that’s happening is that developers, juniors, and seniors alike, at some point in their careers start noticing that: