我想優化我的MySQL表結構的3GB CSV文件。到目前爲止,我已經設法導入19m +行中的60%,MySQL表的大小爲5.5GB。我怎樣才能優化我的表結構來減少數據庫表的大小? (如!我正在運行的磁盤空間不足)文件大小:CSV vs MySQL
CSV文件中的樣本行是
"{0C7ADEF5-878D-4066-B785-0000003ED74A}","163000","2003-02-21 00:00","UB5 4PJ","T","N","F","106","","READING ROAD","NORTHOLT","NORTHOLT","EALING","GREATER LONDON","A"
...和我的數據庫結構是:
(
`transaction_id` int(10) unsigned NOT NULL,
`reference` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`price` int(10) unsigned NOT NULL,
`sale_date` date COLLATE utf32_unicode_ci NOT NULL,
`postcode` varchar(8) COLLATE utf32_unicode_ci NOT NULL,
`type` varchar(1) COLLATE utf32_unicode_ci NOT NULL,
`new_build` varchar(1) COLLATE utf32_unicode_ci NOT NULL,
`tenure` varchar(1) COLLATE utf32_unicode_ci NOT NULL,
`property_number` varchar(10) COLLATE utf32_unicode_ci NOT NULL,
`property_name` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`street` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`area` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`city` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`county1` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`county2` varchar(100) COLLATE utf32_unicode_ci NOT NULL,
`unknown` varchar(1) COLLATE utf32_unicode_ci NOT NULL
)
您可能會問MySQL有關您的數據!嘗試'SELECT * FROM yourtable PROCEDURE ANALYZE;'並查看結果。 – Bjoern 2014-09-13 16:32:02
你爲什麼使用'utf32'編碼?如果這只是ASCII,請使用'utf8'。這是一個很好的解釋:http://stackoverflow.com/questions/496321/utf8-utf16-and-utf32。 – 2014-09-13 16:32:28