The view does not force anything exotic… YugabyteDB simply performs a normal sequential scan of the base table and applies the date-shift expression during projection.
● Only 1 storage read request
● Only 3 rows scanned
● Total execution time was under 1 ms
● No writes, no flushes, no extra catalog work
● Peak memory usage was just 64 kB
So for this kind of pattern, the view is very lightweight. You get “fresh-looking” dates without physically rewriting the table.
⚠️ The Catch: Indexing & Performance on Large Tables
While the view is extremely lightweight for simple reads (as shown in the EXPLAIN), there’s a hidden trap when filtering on the shifted date in large datasets.
Because shifted_date is a computed column, it breaks SARGability.
❌ What Looks Innocent… But Isn’t
SELECT *
FROM v_sample
WHERE shifted_date = DATE '2026-04-15';
👉 This cannot use an index on date_col.
Instead, YugabyteDB must:
● Scan the entire table
● Compute the date-shift expression for every row
● Then apply the filter
🚫 Why You Can’t Just Index It
● The view uses CURRENT_DATE
● CURRENT_DATE is volatile (changes every day)
● PostgreSQL/YugabyteDB require immutable expressions for indexes
👉 Result: You cannot create an index on shifted_date
🛠️ How to Work Around It
Option
When to Use
Filter on date_col
Best option — use original dates in WHERE, and the view for presentation
Permanent UPDATE
When performance matters more than preserving original data
Materialized View
When you want both: preserved data + indexed performance
🔁 Multiple Date Columns?
SELECT
start_date + offset,
end_date + offset
FROM ...
UPDATE t_sample
SET date_col = date_col + (CURRENT_DATE - 1 - DATE '1979-12-31');
🏁 When (and Why) To Use This
● Demo environments with stale datasets
● Replay/testing scenarios
● Synthetic workloads needing realistic time distribution
● Avoiding risky bulk updates on production data
💡 Final Takeaway
Use a view when you want flexibility… not a rewrite. You can instantly modernize timestamps while preserving the original data distribution, making old datasets feel current without any risk or maintenance.
🙌 Acknowledgment
Special thanks to Dan Farrell, Senior Pre-Sales Engineer at YugabyteDB, for providing the detailed insights that helped shape this tip.
Have Fun!
Stopped by Ascension Coffee in Texas with my daughter and ordered their slow drip... turns out it’s brewed on a Kyoto-style cold drip coffee tower that literally takes its time. Worth the wait, but you definitely learn patience watching each drop fall. ☕