Skip to content

Optimize step query #7871

@juliusknorr

Description

@juliusknorr

https://github.com/nextcloud/text/blob/main/lib/Db/StepMapper.php#L23-L36

  • We may not need the version check anymore as we use the id of the step as a version these days
  • We could make use of a combined

Example explain of a document with 4k steps

MariaDB [oc]> EXPLAIN FORMAT=JSON select * from oc_text_steps where document_id = 11824370 and version > 1;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| EXPLAIN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "query_block": {
    "select_id": 1,
    "nested_loop": [
      {
        "table": {
          "table_name": "oc_text_steps",
          "access_type": "ref",
          "possible_keys": ["rd_steps_did_idx", "rd_steps_version_idx"],
          "key": "rd_steps_did_idx",
          "key_length": "8",
          "used_key_parts": ["document_id"],
          "ref": ["const"],
          "rows": 4084,
          "filtered": 50,
          "attached_condition": "oc_text_steps.version > 1"
        }
      }
    ]
  }
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.006 sec)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

📄 To do (~10 entries)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions