Closed Bug 579096 Opened 14 years ago Closed 13 years ago

add an autoinc for collections insertions

Categories

(Cloud Services Graveyard :: Server: Sync, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX
Future

People

(Reporter: tarek, Assigned: tarek)

Details

Attachments

(1 file)

To avoid the select max() done before an insertion, let's use an autoinc in collections.  MySQL will increment a distinct counter per userid as long as collectionid is an autoincrement and part of the composed key.

CREATE TABLE collections (
    userid INT NOT NULL,
    collectionid INT NOT NULL AUTO_INCREMENT,
    name CHAR(30) NOT NULL,
    PRIMARY KEY (userid,collectionid)
) ENGINE=MyISAM;

This alter could be done in the current version, and the PHP server changed consequently (remove the select(max) done before the insert).
This seems fine, but be aware that I believe it makes MySQL5 a requirement for external installations, since I don't think this was a supported feature in 4.

What would probably be better actually would be to have a mysql_mozilla storage type and a mysql storage type that doesn't bother with the extra collections table. Most people don't need this scaling optimization.
MySQL 5 is what, five years old now?  I don't think that's an unfair baseline, for people who aren't running the minimal server.
Tarek, can you fix this?  I think MySQL 5 is a perfectly cromulent min req.
Assignee: telliott → tarek
The barrier here isn't the fix, which is pretty easy - it's that it's not backwards-compatible with the various installs already out there. We should defer it to the 1.5 push.
Changing the milestone accordingly -- The patch follows
OS: Linux → All
Hardware: x86 → All
Target Milestone: --- → 1.5
The patch is written, but it turns out this feature only works for MyISAM. InnoDB does not have this. What engine does our production uses for this table ? Since inserting new collections is quite a rare event, MyIsam should be fine.

In any case, until we get different client-side behaviors, all reads occur in the hardcoded array with the current clients, so it doesn't make a big difference right now. This change is more future-proof though, in case we have more arbitrary collection creations.

Now about backward-compat for the masses: I propose that the next version includes in the Database schema a version number, so we're able to provide DB upgrade scripts like what we'll have in Python. The next version of the minimal and full PHP servers can provide a first upgrade script.

This will also make it simpler for people to move from one of the PHP servers to the Python server without losing their data: the python server will recognize the DB version and upgrade it if needed.
This makes the code uses MyIsam multiple keys autoincrement feature. No DB upgrade script yet, waiting for Toby/Mike feedback before diving into this
Attachment #475477 - Flags: review?(telliott)
Comment on attachment 475477 [details] [diff] [review]
Patch for auto_increment in the collections table

This will work, but it does have all the dangers you've already noted. I would suggest that we hold it for the python version, since that provides a nice break where the user is going to have to do a bunch of stuff anyway, and this isn't an area where the inefficiency is causing us problems right now.
Attachment #475477 - Flags: review?(telliott) → review+
Target Milestone: 1.5 → Future
This is a minor improvement as adding per-user collections is not done by the clients. I am marking it as won't fix
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WONTFIX
Product: Cloud Services → Cloud Services Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: