[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Slow insertion
On Tue, 08 May 2001, Trelio wrote:
> At first it seems cool to use.
> I take one of those examples,
> more precisely, that that comes
> with the tutorial, and try to
> insert 1000 records doing a loop,
> just like this:
>
> ...snip...
> } else if (args[0].equals( "add" )) {
> Garage garage = (Garage)(db.objectForName( "my_garage" ));
> if (garage != null) {
> int i = 1000;
> while (i-- >= 0) {
> garage.addCar_update( "EuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFuscaEuAdoroOMeuFuscaPorqueEleMeLevaAondeQueroQuandoQueroENuncaReclamaPorIssoEuNaoEnchoOTanqueDeGasolinaDoMeuFusca" + Math.random()*100000 , (int)Math.round(((Math.random()*10000) -1)));
> };
> } else {
> System.out.println( "Garage object not found!" );
> }
> ...snip...
>
> For my surprise, I find it slow.
> I didn't time it. I just saw it.
> When it finally finish, I try to
> retrieve the records and they come
> very fast.
>
> Is it so slow for insertions ?
> Is there something that I can
> do to speed it up ?
Please read the documentation at http://ozone-db.org/documentation_main.html.
It's not that much but the user documentation describes why business logic
(like your for-loop) should be placed inside a method of a database class
instead of placing them on the client, where each method call is a network
roundtrip to the server. The ozone model is very comparable to the EJB model (
where you use server side session beans for business logic) in this regard.
Falko
--
______________________________________________________________________
Falko Braeutigam mailto:falko@smb-tec.com
SMB GmbH http://www.smb-tec.com