Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Optimizing SQL Code

Uploaded by

Yazid Erman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Optimizing SQL Code

Uploaded by

Yazid Erman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

MJ ANALYTICS

Manoj Kumar

OPTIMIZING SQL
CODE FOR SPEED

https://www.linkedin.com/in/mk-analytics
MJ ANALYTICS

Manoj Kumar

SQL is a widely used language for querying and


manipulating data in relational databases.

As data volumes grow, optimizing SQL code to run faster


becomes critical.

Here are some techniques for writing high-performance


SQL queries:

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Use Explains to Identify Slow Queries

Most databases provide an EXPLAIN command that shows


the query execution plan. Review explains to find slow
portions of queries that need optimization.

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Create Indexes on Columns in JOINs


and WHEREs

Indexes speed up locating rows that satisfy JOIN and


WHERE conditions. Identify columns frequently
filtered on or joined on and index them.

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Avoid SELECT *

Only select necessary columns instead of using


SELECT * which pulls entire rows. Narrower rows are
faster to process.

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Use Vertical Partitioning

Split wide tables into narrower tables grouped by


columns that are often accessed together. Reduces
rows scanned.

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Incrementally Add Conditions in WHERE

Add conditions progressively in WHERE clauses so initial


filters reduce dataset size for later filters.

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

Use Caching and Temporary Tables

Cache commonly used queries or stages of complex


queries in temporary tables to avoid redundant work.

By applying techniques like indexing, partitioning,


caching, and more you can optimize SQL performance.
Continuously benchmark and profile queries using
explains to find and fix bottlenecks.

Let me know if you have any other SQL optimization best


practices to share!

https://www.linkedin.com/in/mk-analytics/
MJ ANALYTICS

Manoj Kumar

LOOKING FOR REAL-


WORLD EXPERIENCE IN
DATA ANALYTICS?

DM ME ON LINKEDIN TO KNOW MORE


OR
USE 'BOOK A 1:1 CALL' LINK IN MY
PROFILE BIO

https://www.linkedin.com/in/mk-analytics

You might also like