how to reduce the DB operation

B

Baby Lion

while ( get a record from net)
INSERT INTO THE DB



is there any way to reduce the DB operation
it appears to have too much disk operation
the sound from the disk make me afraid


I was thinking about to write the records into a file ,and the transfer
to the db server , and make all of them updated . is it a better way?
 
D

Davide Consonni

Baby said:
I was thinking about to write the records into a file ,and the transfer
to the db server , and make all of them updated . is it a better way?

mysql has bulk insert:

INSERT INTO x (a,b)
VALUES
('1', 'one'),
('2', 'two'),
('3', 'three')

orrible but work ;)
 
C

Chris Brat

If your inserts are all into the same table then you can create a
prepared statement and add the values to it using the addBatch() method
then execute the batch with the executeBatch() method.

This should decrease the overhead to some degree.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top