{"html_url": "https://github.com/dogsheep/github-to-sqlite/issues/35#issuecomment-622982667", "issue_url": "https://api.github.com/repos/dogsheep/github-to-sqlite/issues/35", "id": 622982667, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMjk4MjY2Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-02T16:52:53Z", "updated_at": "2020-05-02T16:52:53Z", "author_association": "MEMBER", "body": "Easiest option: use `db.index_foreign_keys()`: https://sqlite-utils.readthedocs.io/en/stable/python-api.html#adding-indexes-for-all-foreign-keys", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 610511450, "label": "Create index on issue_comments(user) and other foreign keys"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/github-to-sqlite/issues/35#issuecomment-622214262", "issue_url": "https://api.github.com/repos/dogsheep/github-to-sqlite/issues/35", "id": 622214262, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMjIxNDI2Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-01T02:10:32Z", "updated_at": "2020-05-01T02:11:19Z", "author_association": "MEMBER", "body": "This sped that query up even more - down to 4ms.\r\n```sql\r\ncreate index issue_comments_issue on issue_comments(issue);\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 610511450, "label": "Create index on issue_comments(user) and other foreign keys"}, "performed_via_github_app": null} {"html_url": "https://github.com/dogsheep/github-to-sqlite/issues/35#issuecomment-622213950", "issue_url": "https://api.github.com/repos/dogsheep/github-to-sqlite/issues/35", "id": 622213950, "node_id": "MDEyOklzc3VlQ29tbWVudDYyMjIxMzk1MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-05-01T02:09:04Z", "updated_at": "2020-05-01T02:09:04Z", "author_association": "MEMBER", "body": "It sped up this query a lot - 2.5s down to 300ms:\r\n```sql\r\nselect\r\n repos.full_name,\r\n json_object(\r\n 'href', 'https://github.com/' || repos.full_name || '/issues/' || issues.number,\r\n 'label', '#' || issues.number\r\n ) as issue,\r\n issues.title,\r\n users.login,\r\n users.id,\r\n issues.state,\r\n issues.locked,\r\n issues.assignee,\r\n issues.milestone,\r\n issues.comments,\r\n issues.created_at,\r\n issues.updated_at,\r\n issues.closed_at,\r\n issues.author_association,\r\n issues.pull_request,\r\n issues.repo,\r\n issues.type\r\nfrom\r\n issues\r\n join repos on repos.id = issues.repo\r\n join users on issues.user = users.id\r\nwhere\r\n issues.state = 'open'\r\n and issues.user not in (9599, 27856297)\r\n and not exists (\r\n select\r\n id\r\n from\r\n issue_comments\r\n where\r\n issue_comments.user = 9599\r\n and issues.id = issue_comments.issue\r\n )\r\norder by\r\n issues.updated_at desc;\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 610511450, "label": "Create index on issue_comments(user) and other foreign keys"}, "performed_via_github_app": null}