开发者

Is using rand() in an INSERT statement also slow?

开发者 https://www.devze.com 2023-01-17 23:04 出处:网络
The MYSQL rand() function is notoriously slow in select statements, is this true for insert 开发者_如何转开发statements as well?I would like to insert a new row with random number in the following way

The MYSQL rand() function is notoriously slow in select statements, is this true for insert 开发者_如何转开发statements as well? I would like to insert a new row with random number in the following way:

insert into new_table (field1, field2, randomField) values ('Hello', 'Ola', rand());

Will the rand() function become slow as the table gets larger and larger?


Will the rand() function become slow as the table gets larger and larger?

No. RAND() getting slower on big tables is usually when it is used in conjunction with ORDER BY or WHERE. In your example, you are making one call to RAND() which will not be a performance problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号