Best way to store XML data in a MySQL database, with some specific requirements Best way to store XML data in a MySQL database, with some specific requirements xml xml

Best way to store XML data in a MySQL database, with some specific requirements


You could create a blob column (i.e. mediumtext column). Instead of inserting XML purely as strings in the DB, you could zip the XML, then store in MySQL.

When you read from MySQL, you unzip it again. Since XML is text you'll get very high compression rates (close to 80% compression). The thought process being, disk IO takes a lot longer time than compression/un-compression which is predominantly Processor bound.

The downside being you will no longer be able to query or do full text search using SQL....


The best way is to not store XML in the DB, but I have history with that particular issue.

Just store it as TEXT. 500 MB is nothing for MySql, especially with TEXT datatypes, since those aren't stored in the row buffer.


Try to use LOAD XML command. This statement is available in MySQL 5.5.