Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#1073 closed defect (wontfix)

method_save in meta/__init__.py could make use of mysql features

Reported by: Ian@… 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 anonymous, 19 years ago

Component: Admin interfaceDatabase wrapper
Summary: method_save in meta/__init__.py could make use of mysql featuresmethod_save in meta/__init__.py could make use of mysql features

comment:2 by Adrian Holovaty, 19 years ago

This would be a pretty good improvement, I think.

comment:3 by Simon Greenhill, dev@…, 18 years ago

Cc: dev@… 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 Adrian Holovaty, 18 years ago

Resolution: wontfix
Status: newclosed

Closing as a wontfix due to the reasons pointed out by Simon Greenhill.

Note: See TracTickets for help on using tickets.
Back to Top