我有一个直接的问题。性能表(多查询vs单个大查询)的表格布局
我正在做一个使用MySQL的Web应用程序,而且我正在设计它。我只是有一个关于性能的小问题。
我想知道什么是更有效的:
方案1:
Table: Restaurant
-Name
-City
-Province
-Country
-Continent
sql =~ select * from restaurant where id = something.
或
方案2:
Table: Restaurant
-Name
-City
Table: City
-Name
-Province
Table: Province
-Name
-Country
Table: Country
-Name
-Continent
Table: Continent
-Name
sql =~ [insert multiple sql queries that will output the name and the city,
with the corresponding province, country, and continent]
从逻辑上讲,我认为场景#1更好(更少查询),但有些人否则穿给我。
感谢您的快速回复。我将阅读有关规范化数据库结构的文章,因为我现在不太了解这个概念。 – Aktee 2009-10-15 07:08:47
+1。选项1一定会更快。 (但这并不意味着它很好)。它肯定会帮助你,Aktee,了解正常化的优点/缺点(我已经学会了这种痛苦的方式:D) – putolaruan 2009-10-15 07:10:55
谢谢你们,我将使用规范化的数据库。从我读到的内容来看,我不认为性能增益值得受挫。 – Aktee 2009-10-15 07:22:18