Check if a GSI covers all projected columns (covering index query). A covering index includes the indexed field + all payload_fields. If the query projection is a subset, we can serve the query from the GSI without a primary document fetch.
(meta: &GsiMeta, projection: &[String])
| 316 | /// If the query projection is a subset, we can serve the query from |
| 317 | /// the GSI without a primary document fetch. |
| 318 | pub fn is_covering(meta: &GsiMeta, projection: &[String]) -> bool { |
| 319 | if projection.is_empty() { |
| 320 | return false; // SELECT * always needs primary. |
| 321 | } |
| 322 | projection.iter().all(|col| { |
| 323 | col == &meta.field |
| 324 | || col == "id" |
| 325 | || col == "document_id" |
| 326 | || meta.payload_fields.contains(col) |
| 327 | }) |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | #[cfg(test)] |