🚀 Indexing, Hashing & Query Optimization in SQL (with Examples)
dev.to·3h·
Discuss: DEV

Database performance is a critical aspect of any application. Indexing, hashing, and query optimization techniques help speed up data retrieval and reduce execution time. In this post, we’ll explore B-Tree, B+ Tree, and Hash indexing using a Students table.

📌 Step 1: Create the Students Table

CREATE TABLE Students ( roll_no INT PRIMARY KEY, name VARCHAR(50), dept VARCHAR(20), cgpa DECIMAL(3,2) );

📌 Step 2: Insert Sample Records

INSERT INTO Students (roll_no, name, dept, cgpa) VALUES (101, ‘Arun’, ‘CSE’, 8.5), (102, ‘Priya’, ‘IT’, 7.9), (103, ‘Ravi’, ‘CSBS’, 8.2), (104, ‘Sneha’, ‘ECE’, 9.1), (105, ‘Karthik’, ‘EEE’, 6.8), (106, ‘Divya’, ‘CSE’, 7.5), (107, ‘Vikram’, ‘CSBS’, 8.8), (108, ‘Meena’, ‘IT’, 9.0), (109, ‘Hari’, ‘CSE’, 7.2), (110, ’Nisha…

Similar Posts

Loading similar posts...