我桌子的最佳设计表现是什么?

时间:2012-03-26 09:42:47

标签: mysql sql database database-design sqlperformance

我有3张表,他们可以在1table上。它的设计最佳性能是什么? 我需要一个关于搜索和读取的快速数据库,而不是插入。

  1. 这3个表的阅读量将超过写入
  2. 这3张表有超过5百万条记录
  3. 此表“p_apartmentbuy”中可用的大多数字段都用于搜索子句查询(它们已编入索引)并包含搜索结果中显示的一些字段
  4. 此表中的字段“p_apartmentbuydetail”未在搜索子句
  5. 中使用
  6. “pf_contact”表将用于显示某些搜索结果和通常 有些列为空
  7. “具有多个索引的键名”和“每个具有一个索引的几个键名”之间的区别是什么(如附件照片)。 enter image description here

    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;
    

0 个答案:

没有答案