10 Best practices in MySQL 🔥 🔥 🔥

Follow these best practices to make your queries faster and efficient

Note: Please research more about each topic before applying

Thread 🧵
#mysql #CodeNewbie
🦋 1. Add Index key columns 🔥 🔥 🔥

🔸 Always index columns that you plan on searching on
🔸 Index the columns which are used in JOIN clauses so that the query returns the result fast
🔸 Do not use Index for many column, it will slow the Insert or Update
🦋 2. LIMIT 1 When Getting a Unique Row 🔥 🔥 🔥

🔸Adding LIMIT 1 to your query can increase performance
🔸Reduces execution time because the database engine will stop scanning for records after it finds the first match
🦋 3. Always use proper datatype 🔥 🔥 🔥

🔸If you use irrelevant datatypes it may consume more space or may lead to errors
🔸MySQL query optimizer will choose the indexes based on data type you used in query
🦋 4. Use SELECT * only if needed 🔥 🔥 🔥

🔸If there are many columns in the table, all will get returned which will slow down the response time
🔸Particularly if you send the result to a front-end application
🔸Do this instead: SELECT (name,email) ... only
🦋 5. Normalize your data and use joins 🔥 🔥 🔥

🔸Database normalization is the process of organizing columns and tables in relational database to avoid redundancy
🔸This will reduce the column or table and improve the performance
🦋 6. Use CHAR (1) over VARCHAR(1) 🔥 🔥 🔥

🔸If you string a single character, use CHAR(1) instead of VARCHAR(1)
🔸VARCHAR(1) will take extra byte to store information
🦋 7. Log queries in development 🔥 🔥 🔥

🔸It is great to see queries happening in real-time
🔸You will get any error raised behind the scene and you can fix them
🔸It can help you a lot while you are developing.
🦋 8. Avoid using regional date formats 🔥 🔥 🔥

🔸Use DATETIME or DATE datatype always use YYYY-MM-DD date format or ISO date format
🔸This will store exact time and later on your code you can change it as you want
🦋 9. Always try to avoid redundancy 🔥 🔥 🔥
🔸Best database is considered as the one with low or no redundancy
🔸Normalize your database schema to avoid redundency
🦋 10. Always use ID of any column to refer on another table 🔥 🔥 🔥

🔸Connecting tables with IDs like blog_user table connect blog & user table with just 2 fields "user_id" and "blog_id"
🔸Add foreign key on these fields to refer to original table
🦋 Liked this thread

🔸Subscribe to my newsletter bitfumes.com/newsletters
🔸Retweet the main thread
🔸Follow me for more cloud content

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Sarthak (100DaysOfAWS)

Sarthak (100DaysOfAWS) Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Sarthaksavvy

24 Sep
10 Magical Chrome extensions 🔥🔥🔥
For developers

These browser extensions will blow your mind
Some are extremely useful and some are fun to have

🧵 Thread
#codeNewBie #chrome
🦋 1. Bypass Paywalls Chrome

🔸 Bypass Paywalls is a web browser extension to help bypass paywalls for selected sites
🔸Bypass paywall for quora, medium, bloomberg & many many more websites
🔸You need developer mode ON to use this extension
🔸Link 👇
github.com/iamadamdev/byp…
🦋 2. Headless Recorder

🔸A Chrome extension that records your browser interactions
🔸And generates a Playwright/Puppeteer script
🔸Automate your entire browser interaction and tweek the script to do more
🔸Link 👇
checklyhq.com/docs/headless-…
Read 12 tweets
23 Sep
10 Best Practices to use GIT on team 🔥 🔥 🔥

Always ask yourself why you are using any git command

Here consider `main` branch is `production` branch

OK ready ???
Let's make your git experience on amazing 👇

Thread 🧵 #git #github
🦋 1. Never push into main branch🔥 🔥 🔥

🔸Always create new branch & make a Pull Request (PR) to main/master branch
🔸In this way, your main/master branch stay safe
🔸And your code will get pushed only after review from team member
🦋 2. Always have protection on Main branch🔥 🔥 🔥

🔸Set a rule that no one can directly push to main
🔸Main will progress only with the merge of clean PR
🔸It protects your production branches from receiving unexpected and irreversible changes
Read 12 tweets
18 Jun
Learning AWS is one of the best decision I have ever made

Here is why 🧵
1/6
Constantly growing in revenue
The graph below shows that how industry need AWS cloud power

AWS revenue was $13.5 billion, up 32%, and operating profits were a record $4.2 billion
Isn't it a giant
2/6
Fastest Growing Public Cloud Service

By 2020 AWS is expected to increase its market share to 52-percent.

Amazon & Microsoft accounted for more than half of cloud infrastructure revenues in Q4 2020
Read 7 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(