I have two tables
facts_ns_events with around 250 million rows
rule_results with around 5 million rows
both these tables JOINed on a common field flow_id. when I'm trying to do an INNER JOIN query it's very slow.
select rule_results.new_item_value from rule_results JOIN facts_ns_events ON rule_results.flow_id = facts_ns_events.flow_id and rule_results.new_item_type='xyz';
took around 100 seconds
However if in the same query I refer a different column then its get executed extremely fast (.3 seconds)
select rule_results.flow_id from rule_results JOIN facts_ns_events ON rule_results.flow_id = facts_ns_events.flow_id and rule_results.new_item_type='xyz';
How can a different column refer can make such a huge difference?
flow_id is int and new_item_value is varchar(1024).