I have 3 tables that they can be on 1table. What is the best performance for its design? I need a fast database on search and read, not on insert.
- These 3 tables will be read too more than be written
- These 3 tables have more than 5 millions records
- Most of the fields that are available in this table "p_apartmentbuy" are used in the search clause query (they have been indexed) And include some fields that are shown in the search result
- The fields in this table "p_apartmentbuydetail" aren't used in search clause
- "pf_contact" table will be used to show on some search result and usually some columns are null
And what is differences between a "keyname with several indexes" and "several keynames with one index for each one" (like attachment photo).
Relations between tables:
p_apartmentbuy.id = p_apartmentbuydetail.p_apartmentbuy_id (1:1)
pf_contact.id = p_apartmentbuydetail.pf_contact_id (1:1)
CREATE TABLE `p_apartmentbuy` (
`id` mediumint(7) unsigned NOT NULL AUTO_INCREMENT,
`dateadd` int(10) unsigned NOT NULL DEFAULT '0',
`sqm` smallint(5) unsigned NOT NULL DEFAULT '0',
`age` tinyint(2) unsigned NOT NULL DEFAULT '0',
`price` bigint(12) unsigned NOT NULL DEFAULT '0',
`pricemeter` int(10) unsigned NOT NULL DEFAULT '0',
`bedroom` tinyint(1) unsigned NOT NULL DEFAULT '0',
`parking` tinyint(1) unsigned NOT NULL DEFAULT '0',
`storage` tinyint(1) unsigned NOT NULL DEFAULT '0',
`elevator` tinyint(1) unsigned NOT NULL DEFAULT '0',
`describe` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ',
`featured` tinyint(1) unsigned NOT NULL DEFAULT '0',
`pf_source_id` tinyint(1) unsigned NOT NULL DEFAULT '0',
`l_location_id` smallint(5) unsigned NOT NULL DEFAULT '0',
`l_city_id` smallint(4) unsigned NOT NULL DEFAULT '0',
`l_province_id` tinyint(3) unsigned NOT NULL DEFAULT '0',
`pf_status_id` tinyint(1) unsigned NOT NULL DEFAULT '0',
`pf_floor_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`pf_facing_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`pf_cabinet_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`pf_service_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `dateadd` (`dateadd`),
KEY `sqm` (`sqm`),
KEY `age` (`age`),
KEY `price` (`price`),
KEY `bedroom` (`bedroom`),
KEY `parking` (`parking`),
KEY `storage` (`storage`),
KEY `elevator` (`elevator`),
KEY `l_location_id` (`l_location_id`),
KEY `l_city_id` (`l_city_id`),
KEY `l_province_id` (`l_province_id`),
KEY `pricemeter` (`pricemeter`),
FULLTEXT KEY `describe` (`describe`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `pf_contact` (
`id` mediumint(7) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ',
`mobile` bigint(20) unsigned NOT NULL DEFAULT '0',
`telephone` bigint(20) NOT NULL DEFAULT '0',
`telephone2` bigint(20) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `p_apartmentbuydetail` (
`p_apartmentbuy_id` mediumint(7) unsigned NOT NULL,
`address` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ',
`link` varchar(999) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' ',
`sqmland` smallint(5) unsigned NOT NULL DEFAULT '0',
`floortotal` tinyint(3) unsigned NOT NULL DEFAULT '0',
`floorno` tinyint(3) unsigned NOT NULL DEFAULT '0',
`unitno` tinyint(3) unsigned NOT NULL DEFAULT '0',
`unitperfloor` tinyint(1) unsigned NOT NULL DEFAULT '0',
`remotedoor` tinyint(1) unsigned NOT NULL DEFAULT '0',
`iphone` tinyint(1) unsigned NOT NULL DEFAULT '0',
`trase` tinyint(1) unsigned NOT NULL DEFAULT '0',
`sona` tinyint(1) unsigned NOT NULL DEFAULT '0',
`pool` tinyint(1) unsigned NOT NULL DEFAULT '0',
`jackosi` tinyint(1) unsigned NOT NULL DEFAULT '0',
`renovate` tinyint(1) unsigned NOT NULL DEFAULT '0',
`tel` tinyint(1) unsigned NOT NULL DEFAULT '0',
`water` tinyint(1) unsigned NOT NULL DEFAULT '0',
`gas` tinyint(1) unsigned NOT NULL DEFAULT '0',
`electricity` tinyint(1) unsigned NOT NULL DEFAULT '0',
`pf_kitchen_id` tinyint(1) unsigned NOT NULL DEFAULT '0',
`pf_contact_id` mediumint(7) unsigned NOT NULL DEFAULT '0',
`pf_temperaturesystem_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`pf_position_id` tinyint(2) unsigned NOT NULL DEFAULT '0',
`prev_id` smallint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`p_apartmentbuy_id`),
KEY `prev_id` (`prev_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;