Tag: SQL
-
How to Delete from a Table with Foreign Key Constraints in MySQL
I hate foreign keys. They are rarely implemented properly, often times failing to implement cascading deletes and updates. Sure, the concept is sound, and relationships are the first letter in RDBMS, I personally avoid using foreign keys as I find the potential for orphaned data to be way more manageable. While I don’t use foreign…
-
Schedule queries with MySQL
While researching the most performant way to delete a high volume of rows in MySQL, I happened upon some syntax that I had never heard of before. This syntax allows you to run a query on a schedule, without the need of any external code. As a rule of thumb,…
-
Generating UUIDs with MySQL
Universally unique identifiers (UUID) are one of my favorite things. They are easy to generate, without collision, and they make it easy to expose an identifier to end users without it being so obviously guessable, like an automatically incrementing integer value. While they are fantastic, the ability to generate one…
-
Using variables in MySQL queries
Variables. One of the cornerstones of most, if not all, programming languages. They save you time by not having to type the same crap over and over. They can be manipulated for your own gain. They can even be used in your MySQL queries. The declaration syntax for variables in…
-
Add column after another column in MySQL
By default, new columns are added to the end of a table in MySQL. This works well most of the time, but sometimes when you’re retrofitting a column into a table, you may want it to be adjacent columns closer to the start of the table. The ALTER statement makes…
-
How to kill a query on Amazon Relational Database Service (RDS)
Coming from MySQL / MariaDB, I was surprised that I couldn’t kill a query on an Amazon’s Relational Database Service or Amazon Aurora with the kill command. Fortunately, the functionality isn’t omitted, it’ just buried under some AWS RDS specific command. Before we go over that, let’s go over how…
-
Stop Accommodating Shortcomings
I came to a very liberating conclusion the other day. I need to stop fucking around with MySQL, or any other RDBMS, and fully embrace a NoSQL server as my primary data store. I’ve been a huge fan of Redis for quite some time but the fact that everything lives…
-
How to Setup a LEMP Stack on Ubuntu 14.04 LTS
Last week I covered setting up a LAMP server on Ubuntu 14.04 LTS but for my money, it’s all about LEMP stacks. The “E” actually stands for Nginx (pronouced Engine X) and it’s an altnerative to the Apache web server that is built for speed and has a very low…
-
How to Setup a LAMP Stack on Ubuntu 14.04 LTS
The newest long term support release of Ubuntu (Trusty Tahr) is finally here! I just spun up a droplet over on DigitalOcean to walk through setting up a LAMP stack for this post. I also recommend making sure that your system is completely up to date. At the time of…
-
Reducing Redis used memory by moving back to MySQL
If you know me then you know I fucking adore Redis. Over the last few years it’s slowly worked it’s way into the majority of the things I have built. Unfortunately, recently I ran into a problem that Redis could easily accomplish but would require more RAM than I have…