Mysql ( one or few queries)
I'm using ZF to build site. Currently I'm building football forecasts module. Users can place their forecast for different matches and then they got points depending on result of match.
So I have the following system
Tournament->Season->Round->Match
We use User
friend urls so I use aliases as $_GET
params instead of IDs.
tournamentAlias, seasonAlias, roundAlias, matchAlias
Each of them is unique inside of its parent. So there can be 2 season aliases with the same name, but in different tournaments.
So lets ask the question.
For example I have page, where I need to show users table from current SEASON of one of my tournaments.
Url looks like
domain/tournament开发者_如何学编程Alias/seasonAlias
I can get this data using aliases and there will be only one query. But I can also get tournament_ID
and season_ID
, creating 2 queries.
And then I will get users data by IDs. It will work faster than search by aliases. Yes, I can create indexes to make alias-query work faster.
But which way will be better? Find IDs and get users table by IDs or to use aliases?
Create indexes on the alias fields that you are selecting against.
精彩评论