Tecnologia do Blogger.
RSS

Re: [androidbrasil-dev] GreenDAO inserir em lote.


Nunca usei o GreenDAO, estou avaliando-o pra um projeto, e tinha lido o seguinte :


Inserting/updating/deleting entities runs very slow. What's wrong?
Probably, you are inserting/updating/deleting entities without using a transaction. Thus each operation is considered a transaction and SQLite needs to write to disk and do a file sync for each operation. Running all operations in a single transaction is essential for performance (and usually makes sense in terms of consistency). It will run a magnitude faster. For example, running 1,000 inserts in a single transaction ran 500 times faster (!) than 1000 individual transactions in one of our performance tests.

In greenDAO, use DaoSession.runInTx(Runnable) to make the given Runnable run as a transaction. If you have a list of entities of the same type, you can use the insertInTx or updateInTx methods of the DAO class belonging to the entity.


Acho que é esse a solução pro seu problema, não?


On 01/11/2013, at 18:00, Tiago Grillo <tijgrillo@gmail.com> wrote:

Boa tarde,

   Preciso inserir 10.500 produtos numa carga.

   Fiz a parte do DAO na mão pelo sqlLite, agora estou tentando com o GreenDAO, mas ambos demoram muito, cerca de 10 minutos.

   Porém o GreenDAO o metodo:
      List<Produto> p = ...loadAll() é muito rapido.

   Para inserir faço um laço e insero Produto por Produto.

   É isto mesmo? num tem um insertAll()?

   Vocês fazem de algum outro modo ou acham algum outro framework melhor?

ps: no fds farei o teste com o ORMLite

obrigado,
Tiago J. Grillo

--
You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comentários:

Postar um comentário