mercoledì 24 settembre 2008

Yesterday... and plans for today

Yesterday we completed two user stories of our project in java using couchdb4j:

- add a custom field and be able to see it in listings;
- find records by a specific field.

Then we switched to a more difficult task: evaluate the performance differences between CouchDB and MySQL. It's a difficult task because the two databases are logically very different, and it's not easy to find the common operations to test and compare.

In example, the "find" operation in MySQL can be done with a query; it can be a compiled query or an interpreted one.
In CouchDB we need to create a view function and execute it; we can have "named" views - that resemble the MySQL compiled queries - and temporary views, that are executed on demand.

In the CouchDB Futon utility - the web application builtin with CouchDB - it is possible to run a suite of tests and see their execution time.
Editing the file /usr/local/share/couchdb/www/script/couch_tests.js it is possible to modify the default tests or to add new ones, so we quickly wrote a new javascript function to check the execution time of a named view.

Our results were really poor for the first access, when the view is created - around 1 second to create a view on a single field, for a database with only 5000 records; after the view was created, access times were much slower, in the range of 5 to 15 ms.

I don't know if this problem is related to any error we made in the test-writing process, but I'm pretty sure I can exclude this; maybe there is another way to iprove performances of the standard javascript view server, I'll try to find out today. Otherwise, we'll have to change our project, because such a poor performance would make CouchDB not usable in any productive environment.

Keep in touch! Andrea

2 commenti:

  1. Sorry, but you seem to fail to understand that indexing needs to be performed regardless of the technology. A mysql query on a non-indexed field would be just as slow. CouchDB applications should not create views on the fly just like you should only rely on indexed columns in a relational database for the queries you issue in a production system.

  2. Yep, you're right - I understood this today. I still have a lot to learn about DBs! ;) Thanks for posting!