#1073 closed defect (wontfix)
method_save in meta/__init__.py could make use of mysql features
| Reported by: | Owned by: | Adrian Holovaty | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | dev@… | Triage Stage: | Unreviewed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I was looking at method_save, and noticed it might not be the best way of doing it for mysql
in mysql you have got 2 features which might help out a bit.
REPLACE [LOW_PRIORITY | DELAYED]
[INTO] tbl_name [(col_name,...)]
VALUES ({expr | DEFAULT},...),(...),...
http://dev.mysql.com/doc/refman/5.0/en/replace.html
which will replace the record if it already exists
and
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name [(col_name,...)]
VALUES ({expr | DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
http://dev.mysql.com/doc/refman/5.0/en/insert.html
with the ON DUPLICATE KEY UPDATE part allowing you to deal with a duplicate record.
using one of these might simplify the logic going on here, as well as possibly reducing the number of trips to the DB server.
Change History (4)
comment:1 by , 20 years ago
| Component: | Admin interface → Database wrapper |
|---|---|
| Summary: | method_save in meta/__init__.py could make use of mysql features → method_save in meta/__init__.py could make use of mysql features |
comment:2 by , 20 years ago
comment:3 by , 19 years ago
| Cc: | added |
|---|
Just a few points to consider
1) When using InnoDB tables REPLACE INTO will silently delete anything in other tables that reference the replaced field with an ON DELETE CASCADE constraint. This can be quite shocking if you're not expecting it.
2) REPLACE INTO is veeeeeeery slow when compared with an UPDATE.
comment:4 by , 19 years ago
| Resolution: | → wontfix |
|---|---|
| Status: | new → closed |
Closing as a wontfix due to the reasons pointed out by Simon Greenhill.
This would be a pretty good improvement, I think.