I tried to separate the queries and also did not create any relationships. The inner query completes very fast, but the main query (without the sub-query) on the large table still simply appears to hang FileMaker. 30 minutes later....
I also tried to run the main query in the Data Viewer. It got to a point, then was "sorting". However, at some point in that sort, it too hung and I had to FORCE-QUIT FileMaker.
Then trying to restart FileMaker after the necessary Force-Quit, I got the lovely 805 (File Corrupt) message. Running "Recover" didn't (recover). File apparently damaged beyond repair.
This 805 corruption happened twice in the several hours I spent trying to get FileMaker to produce results. Of course, to continue, I had to create a brand new FMP12 file, import 400K records and then 35 K for the other table, then change the field types that the FMP import gets wrong, etc. About a half hour just to create the new FMP12 file for testing after it's corrupted beyond repair following necessary Force-Quit. ("Cancel" button unresponsive).
This FileMaker SQL performance isn't going to fly with my client. I also don't have days to try to find some "trick" to get sub-optimal but still maybe only a few minutes (when SQL Server will do it in a couple seconds). The client knows what his enterprise DB can do
Therefore, he'll (sadly) just end up using MS CRM as it's super fast (SQL Server back end). Sure, not as pretty as FileMaker (or as fun to use, etc.), but functional.
This SQL performance in FileMaker has lost me plenty of business. AFAIK, nothing has changed since ExecuteSQL() was introduced years and years ago. I keep trying ....
Thanks for your reply.
P.S. My experience in MySQL and MariaDB was quite different. I took the client's existing query, made two changes and ran it (5 minutes to make query changes for MariaDB/MySQL). Query runs every time in 3 seconds. Done.