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...
Efficiency in MySQL queries - which is better?
Moderator: General Moderators
-
real_mccoy
- Forum Newbie
- Posts: 2
- Joined: Thu Mar 30, 2006 4:22 am
-
real_mccoy
- Forum Newbie
- Posts: 2
- Joined: Thu Mar 30, 2006 4:22 am
Er..... the latter would be B, the former would be A
You mean you'd rather do the first one? I was thinking I'd rather do that, too, but am a little stumped as to how to iterate through and pick out each day's programs... once I've picked out all of Monday's programs, for instance, I then need to go through the results again and pick out Tuesday's, then ditto for Wednesday's, etc., etc. I just wonder if that's not more inefficient than seven small hits on the database...
What do you think?
What do you think?
Re: Efficiency in MySQL queries - which is better?
Depends on the table, the data, the mysql settings, the OS settings, and more.real_mccoy wrote: 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.
Test in your environment, and find out.