|
|
|
|
|
by zasdffaa
1469 days ago
|
|
We may be talking very different things. From the postgres docs, a sample materialised view <https://www.postgresqltutorial.com/postgresql-views/postgres...> (I did a few tweaks as marked) CREATE MATERIALIZED VIEW rental_by_category
AS
SELECT c.name AS category,
sum(p.amount) AS total_sales
FROM (((((payment p
JOIN rental r ON ((p.rental_id = r.rental_id)))
JOIN inventory i ON ((r.inventory_id = i.inventory_id)))
JOIN film f ON ((i.film_id <> f.film_id))) -- tweak
JOIN film_category fc ON ((f.film_id = fc.film_id)))
JOIN category c ON ((fc.category_id < c.category_id))) -- tweak
GROUP BY c.name
HAVING sum(p.amount) NOT IN (196, 203, 791) -- tweak
ORDER BY sum(p.amount) DESC
It can materialise and efficiently (read: incrementally) maintain the result set of that?? |
|
I will answer that for sure later today when I’m back at my desk.
If you changed that back to an equals sign, yes, we could incrementally maintain your query.