[MDEV-17461] SQL (1031): Not supported by this table type - when try sort field from table by Connect storage engine Created: 2018-10-15 Updated: 2023-04-27 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Connect |
| Affects Version/s: | 10.0, 10.1, 10.3.10, 10.2, 10.3 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Strelkov Andrey | Assignee: | Olivier Bertrand |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | 1031, connect-engine, error, order | ||
| Environment: |
Windows 7 |
||
| Attachments: |
|
| Description |
|
Good day, I have installed MariaDB 10.3 on Windows OS, and on another port MySQL DB. In MySQL I create simple database from example https://github.com/datacharmer/test_db ( load_employees.dump - only 30 row insert) Next I use connect storage engine by next query:
After this, I try to select data from created table, and everything nice
but when I try also SORT
I get error: SQL (1031): Not supported by this table type If I created this sample database and table in MariaDB (not in external database with connect engine) everything works and sorts. That is, what is the problem when sorting varchar fields in connect storage engine? |
| Comments |
| Comment by Strelkov Andrey [ 2018-10-16 ] | ||||||||||||||||||||||||||||||||||||||||
|
More simpe example attach to comment This example create database and one table (example_sort) where created 5 column, and after create connect engine to myself, and this created connect engine can't sort | ||||||||||||||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-10-17 ] | ||||||||||||||||||||||||||||||||||||||||
|
Thanks for the report! Reproduced as described on 10.3.10, 10.0-10.3:
| ||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
Indeed the MYSQL table type is currently missing the facilities to randomly access a remote table that are existing for the ODBC or JDBC table types. I'll be working on adding them the MYSQL type. Meanwhile, there are several turnarounds to avoid this. MariaDB can often do the sorting itself without asking the handler to do it. The conditions are that the table be not too big and the column not too long. This can be handled by setting a higher value of the system variable max_length_for_sort_data. To avoid setting a too big value for large tables, some more tricks can be applied: In some tables the column might be set too long. if a column declared as VARCHAR(255) actually contains values that are no longer than 50 characters, you can define the corresponding column in the CONNECT table as VARCHAR(50) and the sort size will be reduced. For utf8 tables the internal size is larger than the VARCHAR number. This is because for MariaDB the number is the number of characters and can be multiplied by 3 for utf8 charset. Therefore, the sort size can be reduced by not declaring the CONNECT table as utf8. This can be done like this:
It is, by the way, how to have utf8 characters translated to your local charset when reading the table. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Strelkov Andrey [ 2018-10-22 ] | ||||||||||||||||||||||||||||||||||||||||
|
Thanks for reply! Sorry for my weak English, but do I understand that the main problem is that it is difficult to sort the fields of large length, and if the more they are in UTF8 encoding thus takes even more bytes character. I.e. there is at least a solution is to sort by fields less than the number of characters. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-22 ] | ||||||||||||||||||||||||||||||||||||||||
|
Did you try to set max_length_for_sort_data to a larger value (its default value is 1024 that is pretty small). It is the simpler solution if it works. About ODBC, look at the documentation in https://mariadb.com/kb/en/library/connect-odbc-table-type-accessing-tables-from-another-dbms/ the chapter "Random Access of ODBC Tables" describes the different ways to handle the sorting problem. They are what I intend to add to the MYSQL table type. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2018-10-27 ] | ||||||||||||||||||||||||||||||||||||||||
|
Note also that the MYSQL table type is rather a type useful internally for CONNECT. In your case, using the FEDERATED engine also solve your problem because always reading the entire result in memory. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Strelkov Andrey [ 2018-11-12 ] | ||||||||||||||||||||||||||||||||||||||||
|
Sorry for the long answer. Increased the parameter max_length_for_sort_data and the problem is gone! Thanks! | ||||||||||||||||||||||||||||||||||||||||
| Comment by luc willems [ 2019-02-26 ] | ||||||||||||||||||||||||||||||||||||||||
|
we have encountered similar issues using connect to allow us to join tables from different external mariadb databases. we use connect engine because it pushes the WHERE clause to the remote servers , which is important because the data set our current setup : using mysqld 10.3.12-MariaDB-1:10.3.12+maria~bionic in docker container. ERROR 1031 (HY000): SetRecpos not implemented for this table type are there any plans to implement this on the mysql connect as federated doesn't seems to be a option in our case ? | ||||||||||||||||||||||||||||||||||||||||
| Comment by Olivier Bertrand [ 2019-02-26 ] | ||||||||||||||||||||||||||||||||||||||||
|
The message can be different but this is the same limitation. To fix this you can increase the value of the variable max_length_for_sort_data as explained above or use the MEMORY option the same way it is done for the ODBC or JDBC type. Because the on line documentation on MEMORY is unclear and specifies wong values, look at my last comment of There are no plans to implement random access for MYSQL tables because it would be very bad performance wise. |