Hide repeated joins
Give applications a stable, meaningful interface over complex SQL.
CodeBhavyaSeparate reusable query interfaces from stored results, choose useful access paths and read execution plans without guessing.
Current source data remains authoritative.
The database stores the named query.
The result reflects current underlying data.
Give applications a stable, meaningful interface over complex SQL.
Grant access to an approved projection, while remembering that permissions and ownership rules vary by product.
Shield reports from some schema details, but do not treat a view as a guaranteed compatibility layer for every change.
A normal view is expanded into the surrounding query; it usually does not cache rows.
Supports equality, range predicates, ordered traversal and often prefix matching.
Maps a key to a bucket. Excellent for supported equality cases, but generally unsuitable for range ordering.
When all required columns are available in the index and visibility rules permit, the engine may avoid fetching table pages.
INDEX (dept_id, salary) INCLUDE (name)department_id = ?department_id = ? AND salary > ?department_id = ? AND salary = ? AND joined_at > ?salary > ? alonejoined_at = ? alonePut frequently used equality columns before a range column when it matches real workload needs.
Columns after the first range may be less useful for narrowing the seek, though they can still help coverage.
An index on a low-cardinality flag may not save enough table work by itself.
Design from actual predicates, joins, ordering and returned columns—not from a universal formula.
Often best when a large fraction of rows is needed, the table is small, or no useful index exists.
Often best for selective predicates, but scattered table lookups become expensive when many rows qualify.
Possible only when the index covers the query and database visibility conditions allow it.
Some products use bitmap plans between highly selective index access and a full sequential scan.
WHERE created_at >= DATE '2026-01-01'The indexed column remains directly comparable.
WHERE EXTRACT(YEAR FROM created_at) = 2026A normal index on created_at may be harder to use unless a matching expression index exists.
An optimizer estimate in product-specific units—not elapsed milliseconds.
Estimated output cardinality. Large estimate-versus-actual errors can cause poor choices.
How many times an operation ran in an actual plan. Multiply per-loop work when interpreting totals.
Estimated average bytes per output row, which affects memory and I/O estimates.
EXPLAIN estimates without executing in common systems. EXPLAIN ANALYZE actually runs the statement and reports measurements. Use it cautiously with writes or expensive production queries; product syntax and behavior vary.
Capture slow, frequent or resource-heavy statements with representative parameters.
Locate expensive nodes, large row flows, repeated loops and estimate errors.
Review predicates, joins, selected columns, statistics and data distribution.
Rewrite a predicate, update statistics or add the smallest useful index.
Compare latency, reads, writes, storage and plan stability under representative load.
Confirm that other queries and write operations did not regress.
Select a workload and compare candidate indexes. The explanation includes benefits, limitations and write cost.
Change table size, expected matches and index availability. This simplified cost model teaches the optimizer's trade-off; it is not a real database plan.
Read table pages in order.
Educational model: actual optimizers use product-specific costs, statistics, page layout, caching, parallelism and many other factors.
Mark this level when you can justify an access path using workload, selectivity and plan evidence.
Saved in this browser only.