Thanks Karol! I will consider explicit plan if my current rewrite of the query doesn't pan out.
The table "TmpFKExportId" will always have the same number of records, but a different set (each chunk of the batch will load the same number of id:s, but of course different id values). Statistics should be constant. The other tables will vary slightly over time, but the database contains 2+ million companies and related data. During the batch, the only updates to this data is from our TM staff who phone companies and enter data manually, one company at a time. So overall, the change rate is minute. And in particular, there's no big change exactly 318 chunks into the batch job, every time. Yes, the query is hardcoded as a string literal into the app's source code. It can't get more "same" than that. :-) Mvh, Kjell Den 2020-04-30 kl. 17:06, skrev Karol Bieniaszewski liviusliv...@poczta.onet.pl [firebird-support]: > > I suppose you have two different queries – one with where clause and > one without on one of the tables involved in the query. > Are you sure that the queries are the same? > > But also it is quite usual that after new data changes the plan is > about to change. > Is this true for your case that some table got more records after fill > then previously second table? > Especially this one?: > > You can try also modify your query to have static plan (some +0) or > update index statistics after some count of operations. > > Regards, > Karol Bieniaszewski > > [Non-text portions of this message have been removed] > > [Non-text portions of this message have been removed]