Comment 7 for bug 1206936

Revision history for this message
Dan Scott (denials) wrote :

Alternate approach suggested by Mike Rylander: build on the materialized summary table, which will have way fewer rows, and also not require gnarly SQL. So for example:

CREATE OR REPLACE VIEW money.transaction_billing_summary AS SELECT id AS xact, last_billing_type, last_billing_note, last_billing_ts, total_owed FROM money.materialized_billable_xact_summary;

Performance:

EXPLAIN ANALYZE SELECT * FROM money.transaction_billing_summary WHERE xact = 1055743;
                                                                                 QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Index Scan using materialized_billable_xact_summary_pkey on materialized_billable_xact_summary (cost=0.00..6.45 rows=1 width=72) (actual time=0.070..0.070 rows=1 loops=1)
   Index Cond: (id = 1055743)
 Total runtime: 0.094 ms
(3 rows)

Seems good!