0Pricing
System Design Basics for Backend Developers · Ders

Dizinleme ve Sorgu Optimizasyonu

Veritabanı dizinlerinin nasıl çalıştığını, ne zaman kullanılacağını ve yazma işlemlerini aksatmadan hızlı okumalar için sorguların nasıl iyileştirileceğini anlayın.

Dizinleme ve Sorgu Optimizasyonu, CoddyKit'te ücretsiz bir System Design Basics for Backend Developers dersidir. Bu, 4 dersinin 4. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, System Design Basics for Backend Developers öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. System Design Basics for Backend Developers kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

Why Indexes Matter

Without an index, finding a row means scanning every row — a full table scan. As tables grow into millions of rows, this becomes painfully slow.

An index is a separate data structure that lets the database jump straight to matching rows.

The B-Tree Index

Most relational indexes use a B-tree: a balanced tree that keeps keys sorted. Lookups, range scans, and ordering all become logarithmic instead of linear.

  • Fast equality lookups (WHERE id = 5)
  • Fast range queries (WHERE age > 30)
  • Supports ORDER BY without re-sorting

Creating an Index

You create an index on the column(s) you frequently filter or sort by.

Here we index the email column so login lookups are instant.

CREATE INDEX idx_users_email
  ON users (email);

SELECT * FROM users
WHERE email = 'a@example.com';

Composite Indexes

A composite index covers multiple columns. Column order matters: the index helps queries that filter on a left-prefix of the columns.

An index on (country, city) helps WHERE country = ? and WHERE country = ? AND city = ?, but not WHERE city = ? alone.

CREATE INDEX idx_loc
  ON customers (country, city);

Covering Indexes

If an index contains every column a query needs, the database answers from the index alone and never touches the table. This is a covering index.

It is one of the most powerful read optimizations available.

The Write Cost

Indexes are not free. Every INSERT, UPDATE, or DELETE must also update each affected index.

  • More indexes = slower writes
  • More indexes = more storage

Index for the queries you actually run, not speculatively.

Reading EXPLAIN

Use EXPLAIN (or EXPLAIN ANALYZE) to see the query plan. Look for Index Scan (good) versus Seq Scan (full table scan).

EXPLAIN ANALYZE
SELECT * FROM orders
WHERE customer_id = 42;

Selectivity

An index helps most when the column is highly selective — it filters down to a tiny fraction of rows. Indexing a boolean is_active with a 50/50 split is nearly useless; the planner may ignore it.

Avoiding Index-Defeating Queries

Wrapping an indexed column in a function or doing a leading wildcard defeats the index.

  • WHERE LOWER(email) = ? — index on email unused
  • WHERE name LIKE '%son' — leading wildcard, no index

Store data in the form you query, or use a functional index.

-- Defeats the index:
SELECT * FROM users WHERE LOWER(email) = 'a@x.com';
-- Better: store email already lowercased

Indexing and Sharding Together

In a sharded system each shard maintains its own indexes. A query that includes the shard key hits one shard and one index; a query without it must fan out to every shard. Design indexes and shard keys together.

A Practical Workflow

Optimize iteratively: find slow queries from logs, run EXPLAIN, add a targeted (often composite or covering) index, re-measure, and drop indexes that are never used.

Quick Check

Test your understanding of indexing.

Recap

You learned how to make reads fast with indexes:

  • B-tree indexes power equality, range, and ordering
  • Composite indexes follow the left-prefix rule
  • Covering indexes answer queries without touching the table
  • Indexes cost write speed and storage — index deliberately
  • Use EXPLAIN and watch for index-defeating patterns

Sıkça Sorulan Sorular

“Dizinleme ve Sorgu Optimizasyonu” dersi ücretsiz mi?

Evet — “Dizinleme ve Sorgu Optimizasyonu” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve System Design Basics for Backend Developers kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. System Design Basics for Backend Developers kursu toplamda 4 dersten oluşur.

“Dizinleme ve Sorgu Optimizasyonu” dersinde ne öğreneceğim?

Veritabanı dizinlerinin nasıl çalıştığını, ne zaman kullanılacağını ve yazma işlemlerini aksatmadan hızlı okumalar için sorguların nasıl iyileştirileceğini anlayın. System Design Basics for Backend Developers ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

System Design Basics for Backend Developers öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te System Design Basics for Backend Developers, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 4. dersidir.

“Dizinleme ve Sorgu Optimizasyonu” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu System Design Basics for Backend Developers dersinde kod yazıp çalıştırabilir miyim?

Evet. Her System Design Basics for Backend Developers dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. SQL ve NoSQL Veritabanları
  2. Parçalama ve Veri Çoğaltma
  3. Veri Tutarlılığı Modelleri
  4. Dizinleme ve Sorgu Optimizasyonu
← System Design Basics for Backend Developers Sayfasına Dön