Yesterday I had to work on a backfill script to update 24 Million records of payments. Yes, you read right, 24 million. The script ran for 3 hours and wasn´t even at half.
We found several ways to improve its performance today.
Summary below 👇
The first thing was to be able to check performance to make sure we were improving it. So, a sample size of 20k records updates instead of 24 million.
Original query took around 36 seconds. We ended up making this take only 6 seconds, and I think we can´t improve it more now.
1_ Removed an unnecessary join table. We were updating based on a list of descriptions values joined instead of using direct codes. Easier to read by humans, slower for computers. We are at 32 seconds now.
2_ After removal the filter was done with values on a temporal table pre-filled above but still on the where clause. We moved it to a join directly using the code and it improved a little more. 30 seconds. Not even close to good enough just yet.
3_ Now we are using codes directly instead of description. Then 💡, does this table have an index for this code field? No, it didn´t. So, we added the index. Boom, dramatic improve down to 10 seconds now!
Still not good enough. One more step.
4_ Check for triggers on this table. Those slow down a lot. There were 2 triggers. We can´t disable them on prod to all other consumers, so we used a hack with a temp table to avoid executing the trigger when said object is locked, and we lock it on script.
6 seconds now :)!
Of course, I cannot show the code itself. But I could write a short article going more into details about the index and triggers stuff. Let me know if you would be interested in reading about it :)!
I don´t like DB stuff much, but this kind of thing feels great 🔥!
• • •
Missing some Tweet in this thread? You can try to
force a refresh
If you are tired of breaking environments or you keep hearing about DevOps but have no idea what that is...
Then this thread is for you!
Let's talk about CI/CD!
This is the ninth thread of the series: Interview Preparation!
🧵THREAD🧵
First, let's get some definitions down.
CI = Continuous Integration
CD = Continuous Delivery / Continuos Deployment
DevOps = Combination of practices of Software Development (Dev) and IT Operations (Ops)
Let's tackle these concepts and it¿s tools and practices
⬇️
CI/CD is a set of principles and practices to deliver code changes more frequently and reliably
It is one of the best practices for both DevOps teams and agile methodologies, as it goes hand in hand with their objectives:
- Focus on business value
- Code quality
- Automation
Most of the systems you will build in your life will need some form of persistence.
That is why when preparing for an interview you should be ready to talk about Databases
This is the eighth thread of the series: Interview Preparation!
🧵THREAD🧵
First, let's get some definitions down.
A Database is an organized collection of data.
A Database Management System (DBMS) is a software for users to define, create, maintain & control access to the DB.
You will also need a language to program and design your DB objects.
⬇️
There are very different types of Databases & also a lot of possible classifications.
I would say the most useful one is:
- SQL
- NoSQL
We are going to focus only on SQL Databases in this thread.
If you are thinking about FAANG companies or similar this is probably the most important topic. Otherwise, this is still a big topic to cover but don't neglect the others
We will cover a roadmap for Algorithms & Data Structures
⬇️
First let's talk about some easy problems that are widely used in interviews, make sure to be able to solve them.
Read each of them and think of the solution now...
If you can't figure them, search on youtube, there are plenty of videos explaining and solving them.
Javascript is a programming language, the one native for web browsers, and one of the most used in the world.
It allows you to create a front end, back end (node), and even mobile with some magic in the middle. Let's go through the fundamentals that you should learn.
Now it's time to get into the specifics. Do you know how to build Front ends?
This is the 3rd Thread on the series of Interview Preparation
Let's get started!
🧵Thread 🧵
A quick note here: This will focus on web devfront end (some things apply to mobile too), but keep in mind if the position is backend developer, desktop developer, or other fields some things might not apply.
This would be the standard front end check for FullStack Web devs.
👇
First of all, you have to understand:
* What is the Web
* Server-client relationship
* How in the end our web browsers can only process HTML, CSS, and Javascript.