log_min_statement_duration
duration: 100 ms statement:
SELECT * FROM products WHERE
store_id = 1
Slide 32
Slide 32 text
Given a query and
a set of indexes
best indexes to use
Slide 33
Slide 33 text
Given a query and
all possible indexes
best indexes possible
Slide 34
Slide 34 text
/* Allow a plugin to editorialize on
the info we obtained from the
catalogs. Actions might include
altering the assumed relation size,
removing an index, or adding a
hypothetical index to the indexlist. */
get_relation_info_hook
604ffd2
Slide 35
Slide 35 text
hypopg
github.com/dalibo/hypopg
Slide 36
Slide 36 text
SELECT * FROM products
WHERE store_id = 1
AND brand_id = 2
Slide 37
Slide 37 text
EXPLAIN
Seq Scan on products (cost=0.00..1000.00
rows=100 width=108)
Filter: (store_id = 1 AND brand_id = 2)
Final Cost
Slide 38
Slide 38 text
Cost
Hypothetical
Indexes
Original 1000
Slide 39
Slide 39 text
Add hypothetical indexes
store_id
brand_id
Slide 40
Slide 40 text
EXPLAIN
Index Scan using <41072>hypo_btree on
products (cost=0.28..50.29 rows=1 width=108)
Index Cond: (brand_id = 2)
Filter: (store_id = 1) Final Cost
Index
Slide 41
Slide 41 text
Cost
Hypothetical
Indexes
Original 1000
Single Column 50 brand_id
Slide 42
Slide 42 text
Add hypothetical indexes
store_id, brand_id
brand_id, store_id
(does not try different sort orders right now)
Slide 43
Slide 43 text
Cost
Hypothetical
Indexes
Original 1000
Single Column 50 brand_id
Multi Column 45 brand_id, store_id
Slide 44
Slide 44 text
Dexter
github.com/ankane/dexter
Slide 45
Slide 45 text
tail -F -n +1 | dexter
Slide 46
Slide 46 text
--create
--exclude big_table
--min-time 10
Slide 47
Slide 47 text
Shortcomings
Slide 48
Slide 48 text
SELECT * FROM products
WHERE a = 1 AND b = 2
SELECT * FROM products
WHERE b = 2