Hi,
I want to save an invoice, with about 50 rows, with about 50 fields each.
I noticed that, if I want to update already saved rows, mysql needs about 8÷12 times than to delete all rows and insert them.
I.E.:
Delete from InvoiceRow where invoicekey = ?invoicekey
insert into InvoiceRow (InvoiceKey, RowNr, Descr, Qty, Price, [...])
Values (?InvoiceKey, ?RowNr, ?Descr, ?Qty, ?Price, [...])
Need less than 1 second.
Update InvoiceRow Set Descr = ?Descr, Qty = ?Qty, Price = ?Price, [...] Where InvoiceKey = ?InvoiceKey And RowNr = ?RowNR
Insert the unpresent ones, Delete the odds
Need about 8 seconds
I know it should be for updating indexes. I like much more the second method, because I can leave unknown fields of already existing rows untouched.
I tried to set Lock Tables to lock and release indexes, but the taken time does not change. Furthermore, if there is an error, the rollback doesn't work.
Is there a way to tell InnoDB to allow the Rollback and make it to freeze indices and release them after the last update?
Thank you
I want to save an invoice, with about 50 rows, with about 50 fields each.
I noticed that, if I want to update already saved rows, mysql needs about 8÷12 times than to delete all rows and insert them.
I.E.:
Delete from InvoiceRow where invoicekey = ?invoicekey
insert into InvoiceRow (InvoiceKey, RowNr, Descr, Qty, Price, [...])
Values (?InvoiceKey, ?RowNr, ?Descr, ?Qty, ?Price, [...])
Need less than 1 second.
Update InvoiceRow Set Descr = ?Descr, Qty = ?Qty, Price = ?Price, [...] Where InvoiceKey = ?InvoiceKey And RowNr = ?RowNR
Insert the unpresent ones, Delete the odds
Need about 8 seconds
I know it should be for updating indexes. I like much more the second method, because I can leave unknown fields of already existing rows untouched.
I tried to set Lock Tables to lock and release indexes, but the taken time does not change. Furthermore, if there is an error, the rollback doesn't work.
Is there a way to tell InnoDB to allow the Rollback and make it to freeze indices and release them after the last update?
Thank you