There is a big difference in execution time, altough the ammount of table data are pretty much the same in both databases. On production DB - Postgresql 9.0 DB hosted by webprovider it takes 29seconds, versus of Postgresql 9.1 installed on virtual machine.
Also seems when I remove the second condition in ON section it runs fast but when there are both ON conditions it runs super slow.
a) I've tried to change type from varchar(255) to text and vice versa for type reference_number_1 so it would match document_number type varchar(255).
b) Tried to REINDEX command for both tables
SELECT dro.document_number, dro.document_year, dro.document_date, dro.process_id
FROM data_recent_orders dro
LEFT JOIN data_tracking_system dts
ON
dts.reference_number_1_metaapp = dro.document_number AND
dts.reference_number_1_year_metaapp = dro.document_year
WHERE
dro.document_type = 'Sofortrechnung'
LIMIT 10000;
LIMIT
and onOUTER JOIN
. Those aren't touching Your issue but there might be something related to search about.E.24.3.1.1. Performance
andE.24.3.1.2. Optimizer
, that might point to changes responsible for difference in Your execution times.