Data Table based on multiple SQL tables

Data Table based on multiple SQL tables

karpad16karpad16 Posts: 4Questions: 3Answers: 0

I have 5 tables in mysql. Each table has 10 columns and approximately 1 million rows. Each table has the same structure but contains different data values. Does anyone have recommendations on how to query all five tables and how to speed up the process?
I think a VIEW using UNION will work. But I am not sure how to create an index in VIEW.

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    You cannot create in index in a MySQL view but normally the view will use the respective tables' indexes if they are properly designed.
    I would create the VIEW using UNION ALL which normally has superior performance over UNION because it does not try to eliminate duplicates (so UNION should rather be called UNION DISTINCT ... but it isn't).

This discussion has been closed.