add logic of switching query plan in demo.js.