I'm experiencing slow updates with large databases at 30-70K documents.  It 
takes over 50 seconds to delete 200 documents on a database with 50K 
documents.  Is anyone else experiencing slow updates and deletes with 
databases this size?  Any tips on how to optimize it?  Here's some code to 
reproduce the issue, just create 50K documents and time deleting 200. 
 Thanks for any advice on how to speed this up.  This is with Couchbase 
Mobile for Android 1.03 and Samsung Galaxy Tab 4

Thanks -james

            try {
                Manager manager = new Manager( new AndroidContext(app), 
Manager.DEFAULT_OPTIONS);
                Database database = manager.getDatabase( "bigtest7" );

                //create 50k documents
                {
                    long startTime = System.currentTimeMillis();
                    database.beginTransaction();
                    for( int i=0; i<50000; i++ ) {
                        Document document = database.createDocument();
                        Map<String,Object> props = new 
HashMap<String,Object>();
                        for( int j=0; j<10; j++ ) {
                            props.put( "key" + j , "value" + j );
                        }
                        document.putProperties(props);
                    }
                    database.endTransaction(true);
                    long endTime = System.currentTimeMillis();
                    System.out.println("TIME: CREATE:" + 
((endTime-startTime)/1000) );
                }

                //time it takes to delete 200 records
                {
                    List<String> toDelete = new ArrayList<String>();
                    Query query = database.createAllDocumentsQuery();
                    query.setLimit(200);
                    QueryEnumerator enum1 = query.run();
                    while( enum1.hasNext() ) {
                        toDelete.add( enum1.next().getDocumentId() );
                    }

                    long deleteStart = System.currentTimeMillis();
                    database.beginTransaction();
                    for( String toDeleteId:toDelete ) {
                        database.getDocument(toDeleteId).delete();
                    }
                    database.endTransaction(true);
                    long deleteEnd = System.currentTimeMillis();
                    System.out.println("TIME: DELETE:" + 
((deleteEnd-deleteStart)/1000) );
                }

            }
            catch( Exception e ) {
                e.printStackTrace();
            }

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/8a35b1c9-c512-49a8-b96c-3a4321f848f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to