Environment:
MySQL 5.7.10.0 on Windows 10
MySQL 5.7.10.0 on CentOS 6.7
MySQL 5.7.10.0 on RHEL 7
A MySQL temp table was chosen (over a view) because:
- Needed to pass parameter dynamic data for filtering and sorting in the SELECT statement to retrieve user data. With a Temp table that is possible vs a View's select statement cannot contain a variable or a parameter (it's a known limitation).
- NOTE: If a View's select statement could contain variables and parameters it would have been chosen because:
- Data in a view is always current because it is dynamically generated, whereas the data in a temp table reflects the state of the database at the time it was populated and is only created once per session.
- We want to always update the View real-time, even in the same session for a user.
- Temp tables are created per session, so you can have the "same name" temp table across different sessions. MySQL will maintain different "copies" of it.