Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#1073 closed defect (wontfix)

method_save in meta/ 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


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.

    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...

which will replace the record if it already exists


    [INTO] tbl_name [(col_name,...)]
    VALUES ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]

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 Changed 13 years ago by anonymous

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

comment:2 Changed 13 years ago by Adrian Holovaty

This would be a pretty good improvement, I think.

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

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 Changed 12 years ago by Adrian Holovaty

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