[MDEV-11832] CONNECT Engine - ODBC: SRCDEF Views Performance Created: 2017-01-18 Updated: 2017-05-06 Resolved: 2017-05-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Connect |
| Fix Version/s: | N/A |
| Type: | Task | Priority: | Minor |
| Reporter: | Juan Telleria | Assignee: | Olivier Bertrand |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | connect-engine | ||
| Issue Links: |
|
||||||||
| Description |
|
CONNECT » ODBC Engine's Documentation states in section "Accessing specified views" MariaDB Documentation » CONNECT » ODBC Therefore, I would like to suggest that WHERE is also performed in the "Foreing Server", as it allows:
An example would be as follows:
or
Maybe this could be achieved by creating a "derived table" in the Foreing Server (which contains the View), to which the WHERE clause is applied afterwards. Thank you Hope my suggestion is useful! |
| Comments |
| Comment by Juan Telleria [ 2017-01-31 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Also SRCDEF clause has a max. character limitation, which does not allow to perform big queries | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-02-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The simplest solution is to add support for a cond_push where clause to tables based on SRCDEF. Here is a solution I propose that I have successfully implemented and tested:
The %s in the srcdef is a place holder for an eventual where clause made by cond_push. If the select query does not specify a where clause or a where clause not acceptable, it is filled by a dummy where clause (1=1) Therefore if executing:
The query sent to the remote server will be:
Note: A first solution I tested was to replace the place holder by " WHERE " || clause and by nothing when they were no cond_push clauses. This avoids the dummy 1=1 clause but prevent to specify a more complex SRCDEF such as:
If you agree on this solution I will also implement it for MYSQL and JDBC tables. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am quite busy, but I will try to "give a twist" to your implementation by putting several examples in order to check "What would happen" to make it as robust as possible. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Check List:
Would the parser transform it into:
Maybe a good result could be achieved by means of CONCAT functions
For example:
Or it might depend....
In our example, would the result set contain all Customers from our Local Server, and a Boolean Column which indicates us if it is also in the Remote Server's Table.
We shall make it as consistent as possible with the SQL Standard. Thank you Great work! | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
¿Would it be performed in local or remote server? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Oliver, I just realized about a bug with CONNECT ODBC Engine ( JOINS are performed always as INNER JOINs and not LEFT JOINs. It's OK, only people shall be conscious about such behavior. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-02-03 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
When a WHERE Clause can not be applied in the Foreing Server, and it becomes Dummy. Would the SQL Parser drop a "Warning" such as "Condition [...] was convert into Dummy". It might happen that the WHERE Clause is not applicable in SRCDEF View, but yes in the new materialized table, so it might be possible to transfer the table from the Remote Server to the Local MariaDB Server, and filter the table in it. Functions in the WHERE Clause must correspond to those from the Remote Server or from the Local Server When I perform a query which contains a subquery... If several conditions are executed in the WHERE Clause ¿Those which is possible to execute them in the WHERE Clause from the Foreing Server would be executed in such Server; and those which is possible to execute them in the Local Server are executed in the Local Server SELECT query with column definition %s symbol in SRCDEF could give place to an error, as MariaDB DATE_FORMAT function can use such symbol to express seconds | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-04 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Just '%s' symbol is ok. Thank you | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
So in conclusion:
or
Where in the second case, variables consist in a string of type:
That could be created by:
With this previous observations I would consider this little development as closed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-02-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Currently WHERE clause with functions are not kept with ODBC and JDBC but they are kept and executed remotely by MYSQL tables; functions being the same. IN clauses are also eligible for remote execution. About SRCDEF tables, I realized that the problem is far more complex than expected when SRCDEF contains aliases, joins and/or GROUP BY clauses. I am working at a more general solution, but this is not trivial and will take time. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-07 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-02-08 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
What about CONNECT Engine internally creating a derived table:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2017-05-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This now implemented and documented. This was fixed some time ago and should be available in current versions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Juan Telleria [ 2017-05-06 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you |