MySQL Partitioning Multiple Tables - mysql

I'm using MySQL MyISAM and I have 7 tables in my database linked by a primary key called ID. I want to PARTITION the data on one of these tables by its timestamp. When I want to delete a partition, I'd like to delete all records on the other tables with the same ID as the ones I deleted from the partition.
Can this be done at a similar speed as dropping a partition? I don't particularly want to go to each table and search for the right ID to delete as it would defeat the purpose of partitioning in the first place.

Cannot achieve what you want as you stated it.
Are all the tables the same size? Or perhaps the other tables are "normalization" tables? In that case, just leave the data there?
Please elaborate on what kind of data you have and the relationships (1:1, 1:many, etc) between the tables.

You can create triggers for those tables:
http://dev.mysql.com/doc/refman/5.7/en/create-trigger.html

Related

Will MySQL table need re-indexing when new records are inserted?

Do I need to re-index the MySQL table if I insert new records into it? Table has existing indexes.
No, because indexes are updated automatically on any change.
MySQL won't need to re-index the entire table when you insert a new record. It will however need to create an index entry for your newly inserted record.
There is therefore a slight performance impact in creating indexes on tables, in that inserts will take slightly longer. In most practical situations this is acceptable given the big performance improvement you get on reading data from indexed tables.
There is more information available at https://dev.mysql.com/doc/refman/5.0/en/insert-speed.html

Foreign keys for myISAM and InnoDB tables

I have a DB table that is myISAM, used for fulltext searching. I also have a table that is InnoDB. I have a column in my myISAM table that I want to match with a column in my InnoDB table. Can that be done? I cant seem to work it out!
http://dev.mysql.com/doc/refman/5.0/en/innodb-foreign-key-constraints.html
Foreign keys definitions are subject to the following conditions:
Both tables must be InnoDB tables and they must not be TEMPORARY tables.
So, I'm afraid you wont be able to achieve what you want done.
I would recommend altering your DB architecture such that you have one set of tables designed with data integrity for writing (all InnoDB), and a second set designed for search - possibly on a different box, and possibly not even using MySQL, but maybe a search server like Solr or Sphinx, which should outperform a fulltext MySQL table. You could then populate your search DB periodically from your write DB.

Optimize table on huge mysql tables without partition

We have a very huge Mysql table which is MyISAM. Whenever we run optimize table command, the table is locked and performance is getting impacted. The table is not read only and hence creating temporary tables and swapping them may not work out. We are not able to partition the table also.
Is there any other way/tool to achieve optimize table functionality without degrading the performance. Any suggestion would be of great help.
Thanks in advance.
http://dev.mysql.com/doc/refman/5.5/en/optimize-table.html
For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which
rebuilds the table (...)
Therefore, I would not expect any improvement in switching to InnoDB, as Quassnoi probably suggests.
By definition, OPTIMIZE TABLE needs some exclusive access to the table, hence the degraded performances during OPTIMIZE'ation
Nevertheless, there could be some steps to take to reduce the time taken by OPTIMIZE, depending on how your table is "huge" :
if your table has many fields, your table might need to be normalized. Conversely, you might want to de-normalize your table by spreading your columns into several "narrower" tables, and establish one-to-one relations.
if your table has many records, implement a "manual" partitionning in your application code. A simple step would be to create an "archive" table that holds rarely updated records. This way you only need to optimize a smaller set of records (the non-archive table).
optimize table command lock the table,it decrease the performance.
you download percona tool kit command to optimize table.
this command not lock the table during optimize table.
use below link :
https://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html

Is it possible to create a transactional merge table in mysql?

MySQL docs say that tables that use the MERGE storage engine can only union underlying MyISAM tables, which don't allow use of transactions.
Is there an alternative or workaround so that I can have a table that contains the data of several transactional tables in MySQL?
Also, MySQL 4... I know, I know, but it's what I'm stuck with.
Perhaps you could use a view to accomplish this. I'm not too sure if you need the full insert, update, delete functionality or if you just want to select from many tables.

MySQL - Connecting two tables via a Join table - Do all 3 tables need to use the InnoDB engine?

I have 2 tables. Classes and students.
I want to create a table which holds two columns class_ID and student_ID.
My question ,as a mySQL noob, is do all 3 tables need to be set as innoDB so tha I can benefit from cascades if say a student or a class is deleted?
Many thanks.
Yes, it would indeed seem that all tables must be of type innoDB.
You're correct that you'll need to use InnoDB to get support for foreign keys. However, you don't need foreign keys to do cascading deletes as MySQL supports multi-table delete statements. Admittedly, foreign keys simplify things nicely and are probably the way to go.