Skip to content

Commit

Permalink
add foreign key to votes to candidates 28840
Browse files Browse the repository at this point in the history
  • Loading branch information
mickamy committed Jan 2, 2024
1 parent 1053d21 commit 0f75144
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions note.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,19 @@ mysql> EXPLAIN SELECT c.id, c.name, c.political_party, c.sex, v.count
| 1 | PRIMARY | <derived2> | NULL | ref | <auto_key0> | <auto_key0> | 4 | ishocon2.c.id | 128 | 100.00 | NULL |
| 2 | DERIVED | votes | NULL | index | idx_votes_candidate_id | idx_votes_candidate_id | 4 | NULL | 12863 | 100.00 | NULL |
+----+-------------+------------+------------+-------+------------------------+------------------------+---------+---------------+-------+----------+---------------------------------+
```

- add foreign key to votes to candidates 28840

```
❯ make bench
docker exec -i ishocon2-bench-1 sh -c "./benchmark --ip app:443 --workload 6"
2024/01/02 04:26:26 Start GET /initialize
2024/01/02 04:26:26 期日前投票を開始します
2024/01/02 04:26:27 期日前投票が終了しました
2024/01/02 04:26:27 投票を開始します Workload: 6
2024/01/02 04:27:13 投票が終了しました
2024/01/02 04:27:13 投票者が結果を確認しています
2024/01/02 04:27:28 投票者の感心がなくなりました
2024/01/02 04:27:28 {"score": 28840, "success": 26120, "failure": 0}
```
1 change: 1 addition & 0 deletions webapp/ruby/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def db_initialize
db.query('DELETE FROM votes')
db.query('ALTER TABLE votes ADD INDEX idx_votes_candidate_id (candidate_id)')
db.query('ALTER TABLE votes ADD COLUMN count int(4) NOT NULL')
db.query('ALTER TABLE votes ADD CONSTRAINT fk_votes_to_candidate FOREIGN KEY (candidate_id) REFERENCES candidates (id)')
end
end

Expand Down

0 comments on commit 0f75144

Please sign in to comment.