Thursday, October 25, 2012

query on myisam taking long time in stored procedure

There was a very simple query which was taking time inside stored procedure like 20 sec.
If  I execute this query directly on the server, it was taking only 13 milli sec.

Using the Full Process List, I found that mysql was adding collation parameter to the query
 something like

NAME_CONST(' ',_utf8 COLLATE 'utf8_general_ci')

I found that the columns in my table have different char set. If you change the char set of innodb table, it changes for the columns as well, but the same is not the case with myisam.

Collation causes the full table scan instead of using the index.

Corrected the collation, and now it works as expected.



Limitations in MongoDB

I recently started exploring MongoDB for storing unstructured data. The choice to explore MongoDB first was based on statistics showing popularity of NOSQL databases where MongoDB outperform others.

The list of limitations is solely based on my exploration and may not be relevant to the most recent release or upcoming releases as they may have been taken care of

  • Does not support Join. This results into lot of denormalization. Multiple queries needed to collect information
  •  Does not support Transactions though it supports atomic updates.
  • Missing aggregate functions
  • Drivers for different languages have different behavior like the driver for Ruby does not support decimal like in Currency data type. You have to store cents in a different field.
  • Collection name cant be longer than 128 characters.
  • namespace file size is fixed to 16 MB by default which lets it store approx 24,000 namespaces. This means that the number of collection and indexes in your database cant exceed 24,000. This can be changed though.
  • Data file largest pre-allocated size is 2 GB.
  • You cannot delete individual documents from a capped collection nor can you perform any update that will increase size of document.
  • All String values must be encoded in UTF-8. There are plenty of situations where old encoding is used and issues pop-up while importing this data.
  • Issues with Datetime conversion with Ruby driver, not sure if this issue is there with other drivers as well. You cant use date classes that maintain time zone since a BSON datetime cant encode that data. There is no way to create custom BSON type.
  • BSON documents in MongoDB v2.0 are limited to 16 MB in size.