应用程序开发人员常见的数据库开发错误有哪些?
当前回答
I think the biggest mistakes that all developers and DBAs do is believing too much on conventions. What I mean by that is that convention are only guide lines that for most cases will work but not necessarily always. I great example is normalization and foreign keys, I know most people wont like this, but normalization can cause complexity and cause loss of performance as well, so if there is no reason to move a phone number to a phones table, don't do it. On the foreign keys, they are great for most cases, but if you are trying to create something that can work by it self when needed the foreign key will be a problem in the future, and also you loose performance. Anyways, as I sad rules and conventions are there to guide, and they should always be though of but not necessarily implemented, analysis of each case is what should always be done.
其他回答
如果您正在使用复制(MySQL),以下函数是不安全的,除非您正在使用基于行的复制。
USER(), CURRENT_USER() (or CURRENT_USER), UUID(), VERSION(), LOAD_FILE(), and RAND()
参见:http://dev.mysql.com/doc/refman/5.1/en/replication-features-functions.html
1)不了解如何正确地在Java和数据库之间进行交互。
2)过度解析,不恰当或没有重用SQL
3)没有使用BIND变量
4)在数据库中使用SQL集逻辑时,用Java实现过程逻辑(更好)。
5)在投入生产前没有进行任何合理的性能或可伸缩性测试
6)使用水晶报表,在报表中没有正确设置模式名
7)由于不了解执行计划,使用笛卡尔式产品实现SQL(你甚至看了EXPLAIN计划吗?)
我想补充一点: 偏好“优雅”代码而不是高性能代码。在应用程序开发人员看来,对数据库最有效的代码通常是丑陋的。
Believing that nonsense about premature optimization. Databases must consider performance in the original design and in any subsequent development. Performance is 50% of database design (40% is data integrity and the last 10% is security) in my opinion. Databases which are not built from the bottom up to perform will perform badly once real users and real traffic are placed against the database. Premature optimization doesn't mean no optimization! It doesn't mean you should write code that will almost always perform badly because you find it easier (cursors for example which should never be allowed in a production database unless all else has failed). It means you don't need to look at squeezing out that last little bit of performance until you need to. A lot is known about what will perform better on databases, to ignore this in design and development is short-sighted at best.
在修复生产数据库内部的一些问题之前没有进行备份。 在存储过程中的存储对象(如表、视图)上使用DDL命令。 害怕使用存储的proc或害怕在更有效/更合适的地方使用ORM查询。 忽略数据库分析器的使用,它可以准确地告诉您ORM查询最终转换为什么,从而验证逻辑,甚至在不使用ORM时进行调试。
没有做正确的标准化。您希望确保数据没有重复,并且根据需要将数据分割为不同的数据。您还需要确保不要过于遵循规范化,否则会损害性能。
推荐文章
- 模式、表和数据库之间的区别是什么?
- 我看到VARCHAR(255)如此频繁地使用(而不是其他长度),有什么好的原因吗?
- 使用pgadmin连接到heroku数据库
- Delete_all vs destroy_all
- 我如何移动一个redis数据库从一个服务器到另一个?
- 如何首次配置postgresql ?
- 数据库性能调优有哪些资源?
- 如何在PostgreSQL中自动更新时间戳
- 当使用JDBC连接到postgres时,是否可以指定模式?
- 删除MySQL中的主键
- 对象'DF__*'依赖于列'*' -将int改为double
- 将映像存储在MongoDB数据库中
- 重复Mongo ObjectId的可能性在两个不同的集合中生成?
- 用户代理字符串可以有多大?
- 字符串作为SQL数据库的主键