12

Partial indexes only include a subset of the rows of a table.

I've been able to create partial indexes in Oracle, DB2, PostgreSQL, and SQL Server. For example, in SQL Server I can create the index as:

create index ix1_case on client_case (date) 
  where status = 'pending';

This index is cheap since it does not include all 5 million rows of the table, but only the pending cases, that should not exceed a thousand rows.

How do I do it in MySQL?

The Impaler
  • 45,731
  • 9
  • 39
  • 76

2 Answers2

5

As @Gordon Linoff commented, MySQL does not (yet) support partial indexes.

The Impaler
  • 45,731
  • 9
  • 39
  • 76
0

Queries that need the index you suggest may benefit from

INDEX(`status`, `date`)
Rick James
  • 135,179
  • 13
  • 127
  • 222