0Pricing
Firebase Auth & Realtime Database Apps · Ders

Performans İçin Sorguları Dizine Ekleme

.indexOn ile dizinler tanımlayarak, bunların neden önemli olduğunu anlayarak ve dizinlenmemiş sorgu uyarısından kaçınarak Realtime Database sorgularını hızlı ve kurallara uygun hale getirin.

Performans İçin Sorguları Dizine Ekleme, CoddyKit'te ücretsiz bir Firebase Auth & Realtime Database Apps 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, Firebase Auth & Realtime Database Apps öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Firebase Auth & Realtime Database Apps kursu toplamda 4 dersten oluşur.

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

Why Indexing Matters

Querying with orderByChild works on small data, but as nodes grow, unindexed queries force the client to download and sort everything. That is slow and expensive.

Indexes tell Firebase to pre-sort data on the server for a given field.

The Unindexed Warning

Run an orderByChild query on a field with no index and Firebase logs a warning: it had to perform the sort on the client. In large datasets this is a real performance problem.

Declaring an Index

Indexes are declared in your Security Rules using the .indexOn directive at the parent of the records you query.

{
  "rules": {
    "users": {
      ".indexOn": ["age"]
    }
  }
}

Matching the Query to the Index

The indexed field must match the field you order by. This query benefits from the age index above.

import { ref, query, orderByChild } from 'firebase/database';

const q = query(ref(db, 'users'), orderByChild('age'));

Indexing Multiple Fields

You can index several fields under the same node by listing them. Each supports a different orderByChild query.

{
  "rules": {
    "products": {
      ".indexOn": ["price", "rating", "createdAt"]
    }
  }
}

Indexing on $key and $value

For queries using orderByKey or orderByValue, use the special tokens .key and .value in the index list.

{
  "rules": {
    "leaderboard": {
      ".indexOn": ".value"
    }
  }
}

Indexing Under Dynamic Paths

When records sit under a dynamic parent (like per-user lists), put .indexOn inside a wildcard segment so it applies to every child group.

{
  "rules": {
    "posts": {
      "$uid": {
        ".indexOn": ["timestamp"]
      }
    }
  }
}

Indexes Are Free to Maintain

Unlike some databases, Realtime Database indexes add no extra storage cost and are maintained automatically. The trade-off is simply that you must declare them in rules ahead of time.

Index vs Data Structure

Indexing speeds queries, but it does not replace good data modeling. If you constantly query by a field, consider also restructuring data so the common access pattern is a direct lookup.

Limitations to Remember

Keep these constraints in mind:

  • You can order by only one field per query
  • The index field must exist on the child for it to appear in results
  • Deeply nested data is harder to index efficiently

Verifying Your Index

After deploying rules, re-run the query and confirm the unindexed warning is gone from the logs. That confirms the server is now doing the sort.

Quick Check

Test your understanding of query indexing.

Recap

Your queries are now ready to scale.

  • Unindexed orderByChild sorts on the client and warns
  • Declare indexes with .indexOn in Security Rules
  • Match the indexed field to your query field
  • Use .key / .value for key and value ordering
  • Index inside wildcards for dynamic parents

Sıkça Sorulan Sorular

“Performans İçin Sorguları Dizine Ekleme” dersi ücretsiz mi?

Evet — “Performans İçin Sorguları Dizine Ekleme” 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 Firebase Auth & Realtime Database Apps kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Firebase Auth & Realtime Database Apps kursu toplamda 4 dersten oluşur.

“Performans İçin Sorguları Dizine Ekleme” dersinde ne öğreneceğim?

.indexOn ile dizinler tanımlayarak, bunların neden önemli olduğunu anlayarak ve dizinlenmemiş sorgu uyarısından kaçınarak Realtime Database sorgularını hızlı ve kurallara uygun hale getirin. Firebase Auth & Realtime Database Apps 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.

Firebase Auth & Realtime Database Apps öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Firebase Auth & Realtime Database Apps, 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.

“Performans İçin Sorguları Dizine Ekleme” 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 Firebase Auth & Realtime Database Apps dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Firebase Auth & Realtime Database Apps 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. Temel Veri Sorguları
  2. Verileri Filtreleme ve Sıralama
  3. Veri Sayfalandırma Teknikleri
  4. Performans İçin Sorguları Dizine Ekleme
← Firebase Auth & Realtime Database Apps Sayfasına Dön