[MDEV-787] LP:692669 - Bulk Update statement Created: 2010-12-20 Updated: 2018-08-20 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Olaf van der Spek (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Assume strict mode is enabled and I have to update 10000 rows in a table with 100000 rows. The updates are independent of each other (so update xbt_files set leechers = 1 where fid in (1,2) doesn't work). Another way is to execute the updates via update ... case ... when ... then ... else ... end. However, this way can be 20x slower (for 10000 updates) and the syntax is worse. Possible syntax:
The syntax is just a possibility, the semantics are the most important part. How to repeat:
|
| Comments |
| Comment by Kristian Nielsen [ 2010-12-20 ] |
|
Re: Bulk Update statement I think you would be able to achieve most of the needed efficiency this way. |
| Comment by Olaf van der Spek (Inactive) [ 2010-12-20 ] |
|
Re: Bulk Update statement |
| Comment by Kristian Nielsen [ 2010-12-22 ] |
|
Re: Bulk Update statement The main overhead in executing 10000 statements one after the other is in round-trips between the client and server. By sending multiple statements in batches, this overhead is eliminated. |
| Comment by Olaf van der Spek (Inactive) [ 2010-12-22 ] |
|
Re: Bulk Update statement Hmm, I guess benchmarking settles this dispute faster. |
| Comment by Sergei Petrunia [ 2010-12-24 ] |
|
Re: Bulk Update statement – create a temptable with update 'specifications': update xbt_files, updates |
| Comment by Olaf van der Spek (Inactive) [ 2010-12-24 ] |
|
Re: Bulk Update statement |
| Comment by Rasmus Johansson (Inactive) [ 2010-12-24 ] |
|
Launchpad bug id: 692669 |
| Comment by Sergei Golubchik [ 2015-03-05 ] |
|
I suppose the simplest workaround would be to use insert ... on duplicate key update indeed. And specify values for all columns as required. The values don't matter, if they'll never be used anyway. It's a workaround, I agree. A nicer solution would be not to issue “ERROR 1364 (HY000): Field 'info_hash' doesn't have a default value” error if there's a unique key conflict. But it's not easy to implement in a reasonable way. |
| Comment by Olaf van der Spek [ 2018-08-20 ] |
|
> And specify values for all columns as required. The values don't matter, if they'll never be used anyway. Breaks every time I add a field to the table, adding defaults to all fields would be simpler. > It's a workaround, I agree. A nicer solution would be not to issue “ERROR 1364 (HY000): Field 'info_hash' doesn't have a default value” error if there's a unique key conflict. Actually I don't want the insert behavior at all, a dedicated bulk update statement would be ideal. |