Serverless Backend with AWS Lambda & API Gateway · Ders

İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar

Global ve Local Secondary Index'lerin DynamoDB'yi birincil anahtar dışındaki özniteliklere göre sorgulamanızı nasıl sağladığını ve ikisi arasında nasıl seçim yapacağınızı öğrenin.

4. ders / 413 adım

İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar, CoddyKit'te ücretsiz bir Serverless Backend with AWS Lambda & API Gateway 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, Serverless Backend with AWS Lambda & API Gateway öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. Serverless Backend with AWS Lambda & API Gateway kursu toplamda 4 dersten oluşur.

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

The Primary Key Limitation

DynamoDB queries efficiently only by the primary key (partition key, optionally plus sort key). To query by other attributes you need a secondary index.

  • Scanning the whole table is slow and costly
  • Indexes give you efficient alternate access paths

What Is a Secondary Index?

A secondary index is an alternate view of your table data, organized by a different key. DynamoDB keeps it in sync automatically as you write to the base table.

Global Secondary Index (GSI)

A GSI can use any attributes as its partition and sort key, different from the table key. It has its own throughput and can be created anytime.

  • Query by a completely different attribute
  • Spans all partitions of the table
  • Eventually consistent reads only

Local Secondary Index (LSI)

An LSI shares the table partition key but uses a different sort key. It must be created at table creation time and supports strongly consistent reads.

GSI vs LSI at a Glance

Choosing between them:

  • GSI: different partition key, created anytime, eventually consistent
  • LSI: same partition key, created with the table, strongly consistent

Defining a GSI

You specify the index name and its key schema. Reads and writes against the index are billed separately from the base table.

aws dynamodb update-table --table-name Orders \
  --attribute-definitions AttributeName=status,AttributeType=S \
  --global-secondary-index-updates "[{...}]"

Querying an Index

To query a GSI you pass its name and the index key condition. The query returns items matching that alternate key.

aws dynamodb query --table-name Orders \
  --index-name status-index \
  --key-condition-expression "status = :s" \
  --expression-attribute-values '{":s":{"S":"PAID"}}'

Projection: Which Attributes Are Copied

An index projection controls which attributes are copied into it: keys only, a selected set, or all. Projecting fewer attributes saves storage but may force a base-table fetch.

  • KEYS_ONLY: smallest, just keys
  • INCLUDE: keys plus chosen attributes
  • ALL: full copy, biggest

Index Throughput and Cost

GSIs consume their own read and write capacity. Every base-table write that affects an indexed attribute also writes to the GSI, so over-indexing increases cost.

Sparse Indexes

If an item lacks the index key attribute, it is not written to the index. This creates a sparse index, an efficient way to query only items that have a certain attribute set.

Designing Access Patterns First

In DynamoDB you design indexes around your access patterns, not the other way around. List the queries your app needs, then create the minimal set of indexes that serve them.

Quick Check

Test your index knowledge.

Recap

You learned how secondary indexes enable querying DynamoDB by non-primary-key attributes. You compared GSIs (flexible keys, created anytime, eventually consistent) with LSIs (shared partition key, created with the table, strongly consistent), and covered projections, throughput, sparse indexes, and access-pattern-first design.

Başlamak ücretsiz

Yapay zeka eğitmeniyle Serverless Backend with AWS Lambda & API Gateway öğren — ücretsiz

Tarayıcında gerçek kod yaz ve çalıştır, 7/24 yapay zeka eğitmeninden anında yardım al; web'de ya da uygulamada kaldığın yerden devam et.

Kurslar
12
Dersler
48

Sıkça Sorulan Sorular

“İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar” dersi ücretsiz mi?

Evet — “İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar” 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 Serverless Backend with AWS Lambda & API Gateway kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. Serverless Backend with AWS Lambda & API Gateway kursu toplamda 4 dersten oluşur.

“İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar” dersinde ne öğreneceğim?

Global ve Local Secondary Index'lerin DynamoDB'yi birincil anahtar dışındaki özniteliklere göre sorgulamanızı nasıl sağladığını ve ikisi arasında nasıl seçim yapacağınızı öğrenin. Serverless Backend with AWS Lambda & API Gateway 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.

Serverless Backend with AWS Lambda & API Gateway öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te Serverless Backend with AWS Lambda & API Gateway, 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.

“İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar” 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 Serverless Backend with AWS Lambda & API Gateway dersinde kod yazıp çalıştırabilir miyim?

Evet. Her Serverless Backend with AWS Lambda & API Gateway 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. DynamoDB'ye Giriş
  2. DynamoDB Tabloları Tasarlama
  3. Lambda ve DynamoDB Entegrasyonu
  4. İkincil İndekslerle Sorgulama: GSI'lar ve LSI'lar
← Serverless Backend with AWS Lambda & API Gateway Sayfasına Dön