TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2770 5.62K
Now, letโ€™s move to the next topic:

Indexes ๐Ÿš€

๐Ÿง  1. What is an INDEX?

An INDEX is used to make data retrieval faster

๐Ÿ‘‰ Think like a book ๐Ÿ“š
- Without index โ†’ scan every page
- With index โ†’ jump directly to topic

Same happens in databases ๐Ÿ’ฏ

โšก 2. Why Use Indexes?

โœ” Faster SELECT queries
โœ” Faster searching
โœ” Better performance on large tables

โŒ But:
- Uses extra storage
- INSERT/UPDATE become slightly slower

๐Ÿ“Š Visual Understanding

โšก 3. Create an INDEX
CREATE INDEX idx_salary
ON employees(salary);
๐Ÿ‘‰ Creates index on salary column

๐Ÿ” 4. Query Using Indexed Column
SELECT FROM employees
WHERE salary > 50000;
โœ” Faster because of index

โŒ 5. Drop an INDEX
DROP INDEX idx_salary ON employees;

๐Ÿ”ฅ 6. Primary Key Automatically Creates Index
CREATE TABLE employees (
emp_id INT PRIMARY KEY,
name VARCHAR(50)
);

โœ” PRIMARY KEY โ†’ automatically indexed

โšก 7. Types of Indexes

- Primary Index: Created on primary key
- Unique Index: Prevent duplicate values
- Composite Index: Index on multiple columns

๐ŸŽฏ 8. Composite Index Example
CREATE INDEX idx_dept_salary
ON employees(department, salary);

โœ” Useful when filtering both columns together

๐ŸŽฏ 9. Practice Tasks
1. Create index on employee name
2. Create index on department column
3. Create composite index on department + salary
4. Query employees using indexed column
5. Drop created index

โšก Mini Challenge ๐Ÿ”ฅ

๐Ÿ‘‰ Create a unique index on email column

๐Ÿ”ฅ Indexes improve READ speed but may slow down INSERT / UPDATE

Double Tap โค๏ธ For More
  • โค 21
  • ๐Ÿ‘ 4
More from @sqlspecialist
  1. Oct 9, 2026โ€œHere, the data is sorted by the second column in descending order and the first five rowsโ€ฆ
  2. Oct 9, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 6 Guys, let's continue our Data Analyst Interviewโ€ฆ
  3. Oct 9, 2026๐Ÿ‡ฎ๐Ÿ‡ณ ๐—š๐—ข๐—ฉ๐—˜๐—ฅ๐—ก๐— ๐—˜๐—ก๐—ง ๐—ข๐—™ ๐—œ๐—ก๐——๐—œ๐—” โ€” ๐—”๐—œ๐—–๐—ง๐—˜ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ ๐Ÿš€โ€ฆ
  4. Oct 8, 2026๐ŸŽ“ ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜€๐—ผ๐—ณ๐˜ ๐—™๐—ฅ๐—˜๐—˜ ๐—–๐—ผ๐˜‚๐—ฟ๐˜€๐—ฒ๐˜€ ๐˜„๐—ถ๐˜๐—ต ๐—–๐—ฒ๐—ฟ๐˜๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐˜๐—ฒ๐˜€! ๐Ÿš€๐Ÿ”ฅ Upgrโ€ฆ
  5. Oct 7, 2026๐Ÿ“Š Kandinsky 6.0 Video: AI-Powered Content Creation for Analysts The new Kandinsky 6.0 Vidโ€ฆ
  6. Oct 7, 2026Alternatively, depending on the Excel version and requirement, I could use functions suchโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’