Why DBD :: SQLite has a different query plan for the SQL statement

I have an SQL statement insert into ... select ... fromthat runs at an acceptable speed when executed from the SQLite command line command prompt.

However, if I execute the same operator (copy / paste) with Perl DBI::SQLite, the instruction becomes slow.

The reason should be the execution plan: when I allow statemtent to be explained from the shell and from DBI :: SQLite, they are different: the fast version uses the optimal indexes and the order of the tables, the slow version chooses access to the tables in a less optimal way.

So, I have two questions. Why is the plan different? I would not expect this. And how can I make the plan used in the Perl environment the same as in the shell?

+4
source share

Source: https://habr.com/ru/post/1685397/


All Articles