Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

クソデカ・テーブル #3

Open
mirakui opened this issue Oct 5, 2019 · 2 comments
Open

クソデカ・テーブル #3

mirakui opened this issue Oct 5, 2019 · 2 comments

Comments

@mirakui
Copy link
Collaborator

mirakui commented Oct 5, 2019

mysql> show tables;
+------------------------+
| Tables_in_isutrain     |
+------------------------+
| distance_fare_master   |
| fare_master            |
| reservations           |
| seat_master            |
| seat_reservations      |
| station_master         |
| train_master           |
| train_timetable_master |
| users                  |
+------------------------+
9 rows in set (0.00 sec)

mysql> select count(1) from distance_fare_master;
+----------+
| count(1) |
+----------+
|       10 |
+----------+
1 row in set (0.00 sec)

mysql> select count(1) from fare_master;
+----------+
| count(1) |
+----------+
|       81 |
+----------+
1 row in set (0.00 sec)

mysql> select count(1) from seat_reservations;
+----------+
| count(1) |
+----------+
|        0 |
+----------+
1 row in set (0.00 sec)

mysql> select count(1) from station_master;
+----------+
| count(1) |
+----------+
|       82 |
+----------+
1 row in set (0.00 sec)

mysql> select count(1) from train_master;
+----------+
| count(1) |
+----------+
|    70272 |
+----------+
1 row in set (0.02 sec)

mysql> select count(1) from train_timetable_master;
+----------+
| count(1) |
+----------+
|  2807913 |
+----------+
1 row in set (0.21 sec)

mysql> select count(1) from users;
+----------+
| count(1) |
+----------+
|        2 |
+----------+
1 row in set (0.01 sec)
@mirakui
Copy link
Collaborator Author

mirakui commented Oct 5, 2019

CREATE TABLE `train_timetable_master` (
  `date` date NOT NULL,
  `train_class` varchar(100) NOT NULL,
  `train_name` varchar(100) NOT NULL,
  `station` varchar(100) NOT NULL,
  `departure` time NOT NULL,
  `arrival` time NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

index なし

@mirakui
Copy link
Collaborator Author

mirakui commented Oct 5, 2019

0.1 sec くらい

SELECT
          `sr`.`reservation_id`,
          `sr`.`car_number`,
          `sr`.`seat_row`,
          `sr`.`seat_column`
        FROM
          `seat_reservations` `sr`,
          `reservations` `r`,
          `seat_master` `s`,
          `station_master` `std`,
          `station_master` `sta`
        WHERE
          `r`.`reservation_id` = `sr`.`reservation_id` AND
          `s`.`train_class` = `r`.`train_class` AND
          `s`.`car_number` = `sr`.`car_number` AND
          `s`.`seat_column` = `sr`.`seat_column` AND
          `s`.`seat_row` = `sr`.`seat_row` AND
          `std`.`name` = `r`.`departure` AND
          `sta`.`name` = `r`.`arrival`
AND ((`std`.`id` <= '43' AND '43' < `sta`.`id`) OR (`std`.`id` <= '55' AND '55' < `sta`.`id`) OR (`sta`.`id` < '43' AND '55' < `std`.`id`));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant