1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-09 22:24:09 +03:00
Files
mariadb/sql
Oleg Smirnov 7f0201a2b5 MDEV-26278 Add functionality to eliminate derived tables from the query
Elimination of unnecessary tables from SQL queries is already present
in MariaDB. But it only works for regular tables and not for derived ones.

Imagine we have a view:
  CREATE VIEW v1 AS SELECT a, b, max(c) AS maxc FROM t1 GROUP BY a, b

Due to "GROUP BY a, b" the values of combinations {a, b} are unique,
and this fact can be treated as like derived table "v1" has a unique key
on fields {a, b}.

Suppose we have a SQL query:
  SELECT t2.* FROM t2 LEFT JOIN v1 ON t2.a=v1.a and t2.b=v1.b

1. Since {v1.a, v1.b} is unique and both these fields are bound to t2,
   "v1" is functionally dependent on t2.
   This means every record of "t2" will be either joined with
   a single record of "v1" or NULL-complemented.
2. No fields of "v1" are present on the SELECT list

These two facts allow the server to completely exclude (eliminate)
the derived table "v1" from the query.
2022-07-26 22:27:30 +07:00
..
2022-06-09 14:53:34 +03:00
2022-02-09 16:04:49 +02:00
2022-03-22 17:12:15 +04:00
2021-04-20 12:30:09 +03:00
2022-03-23 10:47:27 +11:00
2021-04-21 10:21:47 +04:00
2022-04-06 12:08:30 +03:00
2022-03-14 11:30:32 +02:00
2021-10-26 17:07:46 +02:00
2022-03-14 11:30:32 +02:00
2021-05-19 22:27:48 +02:00
2021-04-22 08:25:40 +03:00
2022-04-21 17:46:40 +03:00
2021-05-19 22:54:12 +02:00
2021-06-21 17:49:33 +03:00
2022-04-06 12:08:30 +03:00
2021-05-19 22:27:48 +02:00
2022-06-28 10:59:01 +03:00
2022-06-28 10:59:01 +03:00
2022-01-04 09:26:38 +02:00
2022-06-28 10:59:01 +03:00
2022-06-28 10:59:01 +03:00
2022-06-02 16:51:13 +03:00
2021-05-09 23:51:18 +02:00
2021-04-20 12:30:09 +03:00
2022-05-19 14:07:55 +02:00
2022-04-06 13:33:33 +03:00
2022-04-06 13:33:33 +03:00
2022-05-19 14:07:55 +02:00
2022-04-06 13:33:33 +03:00
2022-05-19 14:07:55 +02:00
2021-10-13 13:28:12 +03:00
2022-06-28 10:59:01 +03:00
2022-06-28 10:59:01 +03:00
2022-06-07 09:20:07 +03:00
2022-06-07 09:20:07 +03:00
2021-08-26 23:39:52 +02:00
2022-06-07 09:20:07 +03:00
2022-06-06 16:22:09 +03:00
2022-01-27 21:25:07 +02:00
2021-06-21 14:22:22 +03:00
2021-07-16 22:12:09 +02:00
2022-01-19 18:14:07 +03:00
2022-02-09 16:24:19 +02:00
2022-07-26 22:27:29 +07:00
2022-06-09 12:22:55 +03:00
2022-03-14 10:59:46 +02:00
2021-05-19 22:54:13 +02:00
2022-06-09 14:53:34 +03:00
2022-05-19 14:07:55 +02:00
2022-02-03 17:01:31 +01:00
2022-02-10 21:07:03 +01:00
2021-05-19 22:27:48 +02:00
2022-02-01 20:33:04 +01:00
2021-05-19 22:27:48 +02:00
2022-05-19 14:07:55 +02:00
2022-01-27 21:25:07 +02:00
2022-01-27 21:25:07 +02:00
2022-03-30 09:34:07 +03:00
2022-05-10 14:01:23 +02:00
2022-01-04 09:26:38 +02:00
2022-01-04 09:55:58 +02:00
2022-06-28 10:06:00 +03:00
2022-06-09 14:53:34 +03:00
2022-05-09 22:04:06 +02:00
2022-06-28 10:59:01 +03:00
2022-02-04 14:53:19 +01:00
2021-09-30 10:38:44 +03:00
2021-05-19 06:48:36 +02:00
2021-07-02 17:00:05 +03:00
2022-02-04 14:11:46 +01:00
2022-02-04 14:50:25 +01:00
2021-05-19 22:27:27 +02:00
2021-11-09 09:40:29 +02:00
2021-05-19 22:27:48 +02:00
2021-08-18 18:22:35 +03:00
2022-06-29 16:22:22 +03:00
2022-02-03 17:01:31 +01:00
2022-06-28 10:59:01 +03:00
2021-08-02 10:11:41 +02:00
2021-11-17 15:03:47 +02:00
2021-07-31 23:19:51 +02:00
2022-04-21 15:33:50 +03:00
2021-05-19 22:54:13 +02:00
2021-07-02 17:00:05 +03:00
2021-06-30 18:41:46 +03:00
2021-06-01 11:39:38 +03:00
2022-05-10 14:01:23 +02:00
2022-05-06 11:11:04 +03:00
2022-06-28 10:59:01 +03:00
2021-03-27 17:37:42 +02:00
2022-01-20 07:39:11 +02:00
2022-01-29 15:41:05 +01:00
2022-05-09 22:04:06 +02:00
2022-06-07 09:20:07 +03:00
2022-06-27 10:14:37 +03:00
2022-05-11 11:25:33 +02:00
2022-06-28 10:59:01 +03:00
2021-10-31 10:34:19 +01:00
2022-07-26 22:27:29 +07:00
2022-07-26 22:27:29 +07:00
2022-06-02 16:51:13 +03:00
2021-04-20 12:30:09 +03:00
2022-06-28 10:59:01 +03:00
2022-01-19 18:14:07 +03:00
2022-01-19 18:14:07 +03:00
2021-10-28 09:08:58 +03:00
2022-06-28 10:59:01 +03:00
2022-04-06 12:08:30 +03:00
2022-05-11 11:25:33 +02:00
2022-06-07 09:20:07 +03:00
2021-05-19 22:27:48 +02:00
2021-05-19 22:27:48 +02:00
2021-05-19 22:54:14 +02:00
2022-02-04 10:01:08 +01:00
2022-03-22 17:12:15 +04:00
2021-08-02 10:11:41 +02:00
2022-06-28 10:59:01 +03:00
2022-03-29 16:16:21 +03:00
2021-05-19 22:54:12 +02:00
2022-05-19 14:07:55 +02:00
2022-05-07 11:48:15 +02:00
2022-06-07 09:20:07 +03:00
2021-05-19 22:27:48 +02:00
2022-02-01 20:33:04 +01:00
2022-06-28 10:59:01 +03:00
2022-03-29 11:13:18 +03:00
2022-06-21 18:19:24 +03:00
2022-03-30 09:34:07 +03:00
2022-03-18 12:17:11 +11:00
2022-04-13 17:52:27 +09:00
2022-02-02 01:35:40 +01:00
2022-06-02 16:51:13 +03:00
2022-06-02 17:39:13 +03:00
2021-12-26 12:51:04 +01:00
2022-06-07 09:20:07 +03:00
2022-03-30 09:41:14 +03:00
2022-02-03 17:01:31 +01:00
2022-06-28 11:27:49 +02:00
2022-06-27 10:14:37 +03:00
2022-03-18 20:50:10 +01:00
2022-01-29 15:41:05 +01:00
2021-12-26 12:51:04 +01:00
2022-04-28 15:54:03 +03:00