how can i query a table that got split to 2 smaller tables? Union? view ?

Posted by danfromisrael on Stack Overflow See other posts from Stack Overflow or by danfromisrael
Published on 2010-06-06T16:59:36Z Indexed on 2010/06/06 17:02 UTC
Read the original article Hit count: 179

Filed under:
|
|
|
|

hello friends, I have a very big table (nearly 2,000,000 records) that got split to 2 smaller tables. one table contains only records from last week and the other contains all the rest (which is a lot...) now i got some Stored Procedures / Functions that used to query the big table before it got split. i still need them to query the union of both tables, however it seems that creating a View which uses the union statement between the two tables lasts forever... that's my view:

CREATE VIEW `united_tables_view` AS select * from table1 union select * from table2;

and then i'd like to switch everywhere the Stored procedure select from 'oldBigTable' to select from 'united_tables_view'...

i've tried adding indexes to make the time shorter but nothing helps... any Ideas?

PS the view and union are my idea but any other creative idea would be perfect! bring it on! thanks!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about query