插入数据用UNIQUE好呢仍是插入前用count(*)查询效率高?
Jun 13, 2016 am 11:46 AM
插入数据用UNIQUE好呢还是插入前用count(*)查询效率高??
一个表不允许插多条 title + url 同时相同的数据。
方式A: 用 UNIQUE 约束,代码只需直接执行语句 insert ignore into ........
方式B: select count(*) from mytable where title=? and url=?
结果为零才执行 insert into ....
哪种方式效率高点呢?
------解决方案--------------------
怎么也是第一种方式效率高……
------解决方案--------------------
同意楼上,但是没做过测试

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solution: Your organization requires you to change your PIN

How to adjust window border settings on Windows 11: Change color and size

How to change title bar color on Windows 11?

How to enable or disable taskbar thumbnail previews on Windows 11

OOBELANGUAGE Error Problems in Windows 11/10 Repair

10 Ways to Adjust Brightness on Windows 11

How to turn off private browsing authentication for iPhone in Safari?
