Efficiency in MySQL queries - which is better?
Posted: Thu Mar 30, 2006 4:30 am
Hi Folks,
I have been using PHP/MySQL for a couple of years now, and am attempting to develop a "program guide", which lists radio or tv programs in a weekly schedule. The issue I am facing is this: I have decided to have each weekday as a field in the table, and if the program occurs on multiple days, those days will have the value "Y". When I go to display the program guide, I am wondering if I should:
A. pull all of the data out of the table and iterate through it multiple times, in order to display each day's programs consecutively - OR
B. conduct seven separate queries on the table, only pulling items which are marked for each day to display (i.e., "where Mon = 'Y'").
All told, there will only be about 100 items at most in the table, so it won't be a huge hit anyway. I'm just wondering what the most efficient way is to do it.
Opinons?
thanks in advance...
I have been using PHP/MySQL for a couple of years now, and am attempting to develop a "program guide", which lists radio or tv programs in a weekly schedule. The issue I am facing is this: I have decided to have each weekday as a field in the table, and if the program occurs on multiple days, those days will have the value "Y". When I go to display the program guide, I am wondering if I should:
A. pull all of the data out of the table and iterate through it multiple times, in order to display each day's programs consecutively - OR
B. conduct seven separate queries on the table, only pulling items which are marked for each day to display (i.e., "where Mon = 'Y'").
All told, there will only be about 100 items at most in the table, so it won't be a huge hit anyway. I'm just wondering what the most efficient way is to do it.
Opinons?
thanks in advance...