materialize icon indicating copy to clipboard operation
materialize copied to clipboard

doc/user: Index optimization

Open joacoc opened this issue 2 years ago • 1 comments

Motivation

Preview

Board one of the two issues mentioned in https://github.com/MaterializeInc/materialize/issues/12700

The main idea is to improve how we communicate optimizations for query performance using indexes.

How?

  1. Moving it to Operating Materialize
  2. Adding an executable example and follow-through
  3. Providing ways to know when an index is in use. [Right now, it is difficult, there is another PR (https://github.com/MaterializeInc/materialize/pull/12597) to at least display when a query is using an Index]
  4. Providing ideas on how to use them (Temporal Filters / Expressions / Patterns) [The pattern is Manual Materialization. It should be explained in the patterns section rather than here.]

Tips for reviewer

  1. Part of the content was already in the CREATE INDEX section. I've translated it to a particular example and separated it into sections.
  2. I'm using tables for the example because they make it accessible and easy to try.
  3. I'm open to any suggestions.
  4. If we call the section Optimizations rather than Index, we can include things like how workers, hardware, or clusters can improve the performance, but at the same time, it could be mixing up too many things.

At first I added something playful to understand Materialized Views default index but it sounded not much correct for an Operating Materialize section:

Which query should run faster?

-- a)
SELECT * FROM phones WHERE first_name = 'Jann';

-- b)
SELECT * FROM phones WHERE first_name = 'Jann' and last_name = 'Johnson' and phone = 12233344;

At first a) sounds like the candidate since it's filtering by one field, but answer b) is the correct one! It's more than ten times faster than the alternative option (it can vary by setup).

Testing

  • [ ] This PR has adequate test coverage / QA involvement has been duly considered.

Release notes

This PR includes the following user-facing behavior changes:

joacoc avatar Jun 15 '22 21:06 joacoc

I am requesting a re-review after applying all the items discussed.

joacoc avatar Aug 08 '22 12:08 joacoc

@mjibson I have widely changed the way index creations are displayed. Uses tables rather than big sections. The text still needs some tweaks, but what do you think about the new approach

joacoc avatar Sep 14 '22 16:09 joacoc