MySql performance -- joining to a view

I am running MySql 5.

I have a table that does effectivity dating to track users.  When a user goes inactive, has his performance goal changed, has his phone extension changed, etc., a new record is added.

I have a view on this table that presents the current data -- current active state, phone extension, performance goal, etc.

Currently the table has 346 records and the view 53.

I have a complex query that joins to the view.  But I can't add indexes to a view:

An EXPLAIN on the complex query suggests table scans of the table itself.

How should I optimize this?  Do I need to optimize the view itself by adding indexes to the table?  Surely I should not replace the view references in my complex query by pasting in the view definition as a derived table!

LVL 32
Daniel WilsonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


I don't believe mySQL supports anything like Oracle's 'Materialized Views.'  It's been talked about but I don't believe it ever happened.  mySQL views can however use the indexes on the underlying tables.  Sometimes, you may have to include a column in the view that is indexed (to join on) that you wouldn't normally need in the view.  I also believe you can use index hints in your query.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Daniel WilsonAuthor Commented:
Thanks.  That confirmed what I suspected.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.