Different queries will take different amounts of time to execute. We'd need to see these similar cases which are faster to advise. We'd also need to see your table definition, including indexes, and a rough idea of how many rows there are. Finally, the output of
explain SELECT Subject, Code FROM blockPeriodsTable WHERE dataIndex={num} AND Block='A'
will give a lot of information about the performance of the query.