forked from LibriVox/librivox-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use SELECT DISTINCT where possible
SELECT DISTINCT is bad for performance because it forces the use of temporary tables [1]. Stop using it. As far as we could tell in our testing, a simple s/SELECT DISTINCT/SELECT/ is enough in most places, except two. First, when listing a reader's projects. Readers are associated with sections, not projects, and there's a many-to-one relation between sections and projects, so we need the SELECT DISTINCT to avoid repeating the project once for every section for a particular reader. Second, when listing users according to a specific role. There's a one-to-many relation between users and roles, and the latter are stored as rows in the database. We need the SELECT DISTINCT to avoid listing a user once for every role that they have. Other than that, we seem to be able to get away with just not doing DISTINCT. [1] https://dba.stackexchange.com/questions/34674/mysql-performance-tuning-queries-stuck-on-copying-to-tmp-tables Resolves: LibriVox#82
- Loading branch information
Showing
5 changed files
with
33 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters