{"id":16683553,"url":"https://github.com/yamachu/sql-index-helper","last_synced_at":"2025-04-23T18:27:15.027Z","repository":{"id":210917675,"uuid":"727759535","full_name":"yamachu/sql-index-helper","owner":"yamachu","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-05T14:39:36.000Z","size":67,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T02:22:32.754Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yamachu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-05T14:16:43.000Z","updated_at":"2024-12-03T12:00:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"79e39d6c-58cb-480f-90aa-231240cd89c0","html_url":"https://github.com/yamachu/sql-index-helper","commit_stats":null,"previous_names":["yamachu/sql-index-helper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamachu%2Fsql-index-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamachu%2Fsql-index-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamachu%2Fsql-index-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yamachu%2Fsql-index-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yamachu","download_url":"https://codeload.github.com/yamachu/sql-index-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250489175,"owners_count":21438922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T14:25:16.480Z","updated_at":"2025-04-23T18:27:15.000Z","avatar_url":"https://github.com/yamachu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SQL Index Helper\n\nISUCONで、Node.js実装のソースコードからSQLを解析し、INDEXを貼るサポートを行うツール。\n\n## Usage\n\n### Install\n\n```sh\n$ npm i @yamachu/sql-index-helper\n```\n\n### Collect SQL\n\n```sh\n$ npx --yes jscodeshift --dry -s -t node_modules/@yamachu/sql-index-helper/dist/transforms/index.js --extensions ts targetFile_or_directory \u003e collected_sql.log\n```\n\n### Create Index\n\n```sh\n$ npx sql-index-helper -f collected_sql.log \n```\n\n### Dump SQL\n\n```sh\n$ npx sql-index-helper -f collected_sql.log -t dump\n```\n\n### Dump CRUD\n\n```sh\n$ npx sql-index-helper -f collected_sql.log -t crud\n```\n\n## Example\n\n### Create Index\n\n```sql\n-- start: auto generated add index --\n\n-- competition\n--       SELECT * FROM competition WHERE id = ?\n-- ALTER TABLE competition ADD INDEX idx_id (id);\n--       SELECT * FROM competition WHERE tenant_id=? ORDER BY created_at DESC\n--       SELECT * FROM competition WHERE tenant_id = ? ORDER BY created_at DESC\n--       SELECT * FROM competition WHERE tenant_id = ? ORDER BY created_at ASC\nALTER TABLE competition ADD INDEX idx_tenant_id_created_at (tenant_id, created_at);\n--       SELECT * FROM competition WHERE tenant_id = ?\nALTER TABLE competition ADD INDEX idx_tenant_id (tenant_id);\n-- my_player_score\n--       SELECT player_id FROM my_player_score WHERE tenant_id = ? AND competition_id = ?\nALTER TABLE my_player_score ADD INDEX idx_player_id_tenant_id_competition_id (player_id, tenant_id, competition_id);\n--       SELECT * FROM my_player_score WHERE tenant_id = ? AND competition_id = ? AND player_id = ?\nALTER TABLE my_player_score ADD INDEX idx_tenant_id_competition_id_player_id (tenant_id, competition_id, player_id);\n-- player\n--       SELECT * FROM player WHERE id = ?\n-- ALTER TABLE player ADD INDEX idx_id (id);\n--       SELECT * FROM player WHERE tenant_id = ? ORDER BY created_at DESC\nALTER TABLE player ADD INDEX idx_tenant_id_created_at (tenant_id, created_at);\n-- tenant\n--       SELECT * FROM tenant ORDER BY id DESC\n--       SELECT * FROM tenant WHERE id = ?\n-- ALTER TABLE tenant ADD INDEX idx_id (id);\n--       SELECT * FROM tenant WHERE name = ?\nALTER TABLE tenant ADD INDEX idx_name (name);\n-- visit_history_min\n--       SELECT player_id, created_at AS min_created_at FROM visit_history_min WHERE tenant_id = ? AND competition_id = ?\nALTER TABLE visit_history_min ADD INDEX idx_player_id_created_at_tenant_id_competition_id (player_id, created_at, tenant_id, competition_id);\n-- start: could not determined index --\n--       SELECT score, row_num, player_id, p.display_name as display_name FROM my_player_score mpc left join player p on p.id = mpc.player_id WHERE mpc.tenant_id = ? AND competition_id = ? ORDER BY row_num DESC\n-- end: could not determined index --\n-- end: auto generated add index --\n```\n\n## LICENSE\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamachu%2Fsql-index-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyamachu%2Fsql-index-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyamachu%2Fsql-index-helper/lists"}