Jump to content

Recommended Posts

I thought using the default value of a table column would be a good way to store a semi static variable (rarely updated) but I seem to have come upon a problem when the record count is increase greatly.

 

The following query to update the default value startes to take over a second to process once the record count is over 100,000 (>500,000 takes about 3 seconds and over a million would take over 6 seconds since the process time is very proportional):

 

ALTER TABLE reimbursement MODIFY rate FLOAT NOT NULL DEFAULT 0.95 COMMENT 'currency rate per kilometre';

 

The fact that updates are very rare to being with and the process time is arbitrary is beside the point here... the point is, why is the result of the above query:

 

(655360 row(s)affected)

(0 ms taken)

 

... or what ever record count row(s)affected ????

 

All that needs changing is the default value...

 

... why is there any affect on current records?

... and is there a simpler way to change the default value (with no affect on current records)?

 

EDIT:

 

What the heck does this mean?:

 

ALTER COLUMN specifies a new default value for a column or removes the old default value. If the old default is removed and the column can be NULL, the new default is NULL. If the column cannot be NULL, MySQL assigns a default value, as described in Section 13.1.5, “CREATE TABLE Syntax”.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.