Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.3.3-1
Description
SQL Standards starting from SQL-1999 uses the construct <table value constructor> as
one of the alternatives for <simple table>:
<simple table> ::=
|
<query specification>
|
| <table value constructor>
|
| <explicit table>
|
Currently MariaDB uses <table value constructor> only in insert statements:
INSERT INTO t VALUES (1,'xx'), (5,'yyy'), (1,'zzz'); |
With <table value constructor> it will be possible to use such CTE specification:
WITH t (a,c) AS (SELECT * FROM VALUES (1,'xx'), (5,'yyy'), (1,'zzz')) ... |
Now instead of this we have to use something like this:
WITH t (a,c) AS (SELECT 1, 'xx' UNION ALL SELECT 5, 'yyy' UNION ALL 1, 'zzz') ... |
Processing of the latter will take much more memory.
Besides with the possibility of using table value constructors in CTE specifications some optimization transformations for IN predicates will be possible.
Attachments
Issue Links
- blocks
-
MDEV-12176 Transform [NOT] IN predicate with long list of values INTO [NOT] IN subquery.
-
- Closed
-
Second evaluation results:
( see the the list of commits here https://github.com/MariaDB/server/compare/10.3...shagalla:10.3-mdev12172 )
Queries where TVC(s) are used are processed successfully.
TVCs can be used separately as in:
values (1,2);
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
+---+---+
with UNION/UNION ALL:
values (1,2) union select 1,2;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
+---+---+
in derived tables:
select * from (values (1,2),(3,4)) as t2;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
| 3 | 4 |
+---+---+
views:
create view v1 as values (1,2),(3,4);
select * from v1;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
| 3 | 4 |
+---+---+
and non-recursive common table expressions:
with t2 as (values (1,2),(3,4)) select * from t2;
+---+---+
| 1 | 2 |
+---+---+
| 1 | 2 |
| 3 | 4 |