Open yazun opened 2 years ago
TBase(PGXL) does not support Index Predicate, because when CopyFrom data, the DN process is waiting for the arrival of data. At this time, it cannot receive other commands from CN. The DN stack is as follows:
The existence of Index Predicate causes CN to enter the RelationGetIndexPredicate logic during CopyFrom, and then enter ExecRemoteQuery to send "SELECT val FROM test_copy_fn_lookup WHERE (id = 10) " to DN. CN stack information is as follows:
However, DN is in the process of waiting to receive copy data and cannot process other Query messages sent by CN.
Insert into is supported to insert one piece of data at a time, because the copy from logic is not executed, but when insert into multiple pieces, it will be automatically converted to copy from and the same problem will occur
functions in index predicate can not be STABLE:
We found that a functional index with an immutable function does not work with copy API. It works while inserting normally. Marking the function as stable enables the index (at the performance price of course).
The snippet belows demonstrates this:
Then copy any data into the table:
As in the comments, changing the function to STABLE will enable the copy, the error is gone but obviously performance drops. The error is visible in 2.2 and 2.3 as well...